Page 1 of 1

compose one transparent png(as mask) with one jpg

Posted: 2019-09-28T05:57:50-07:00
by andrea70
I have 2 type of images.

Some hundreds of png images with just one color(gray) and some transparent zones then must be transparent even in final result.

Over 30 thousands of jpg images with many size. I must estrapolate from jpg images the gray zones of png files.

Now i use something like this :

convert JPG_FILE.jpg -resize WIDTH_OF_PNGxHEIGHT_OF_PNG^ -gravity Center -crop WIDTH_OF_PNGxHEIGHT_OF_PNG+0+0 -alpha Set PNG_FILE.png ( -clone 0,1 -alpha Opaque -compose Hardlight -composite ) -delete 0 -compose In -composite RESULT_IMAGE.png

it works very good but its a bit slow

any suggestion for faster execution?

Re: compose one transparent png(as mask) with one jpg

Posted: 2019-09-28T08:24:31-07:00
by snibgo
What version of IM, on what platform? Can you link to sample input and output images?

Perhaps your IM is Q16 HDRI but your requirement needs only Q8 non-integer.

Re: compose one transparent png(as mask) with one jpg

Posted: 2019-09-28T09:50:35-07:00
by andrea70
i post some example not with real image, i cant .... these are not mine
but the result image dosent show pretty any Hard Light effect then i need in real application because the images are very small
the real masks(png) are around 1200x3000 px and jpg images are even bigger, this help to show lot better the little but nice Hard Light effect on the borders


jpeg example
Image
mask example
Image
result example
Image

this is what i used
convert jpeg_example.jpg -resize 300x500^ -gravity Center -crop 300x500+0+0 -alpha Set mask_example.png \( -clone 0,1 -alpha Opaque -compose Hardlight -composite \) -delete 0 -compose In -composite result.png

the blue line at end are just an error of miniatures, my images are fine :lol:

Re: compose one transparent png(as mask) with one jpg

Posted: 2019-09-28T09:57:04-07:00
by magick
We're using ImageMagick 7.0.8-66, the latest release, and HDRI is not enabled. Your command completes for us in 9 one-hundreds of a second.

Re: compose one transparent png(as mask) with one jpg

Posted: 2019-09-28T11:35:02-07:00
by andrea70
im on ubuntu 18.04.3 with imagemagick 6.8

wtf .... with real image i did just 1 convert every 0,41 sec at 100% cpu :?

maybe php even with shell_exec its not a good idea for mass converting :oops: , but helps me alot to keep tracking what's i have done, manage errors and so on ... even directory tree its a pain
im not an bash fan outside easy tasks :lol:

i will try something different because i have to covert too many images, at this rate i need months