Page 1 of 1

Single combined command != multiple commands

Posted: 2012-11-20T08:18:12-07:00
by yoav.gonen
Hi,
I'm using IM v6.8.0-3, and I have a case in which the outcome of multiple commands isn't the same as the output of a combined command.
I have two 300x300 images, img1.jpg and img2.png (the second with transparency). Using the following commands:

Code: Select all

convert img2.png img1.jpg -compose In -composite out.png
convert out.png -background white -extent 0x0 +matte out.jpg
produces an image with white where there was transparency. Combining the two:

Code: Select all

convert img2.png img1.jpg -compose In -composite -background white -extent 0x0 +matte out.jpg
produces a similar image, but the transparent areas are not white (they are black, but I'm not sure this is not "garbage" black from the conversion to JPG).
Shouldn't the result be identical?
As a side note, what I'm trying to do is combine the two images so that wherever the PNG is transparent would be white, and everywhere else would be the content of the JPG. Any idea how to do this other than the way I'm doing it?
Thanks,
Yoav

Re: Single combined command != multiple commands

Posted: 2012-11-20T11:29:30-07:00
by fmw42
convert img2.png img1.jpg -compose In -composite -background white -extent 0x0 +matte out.jpg
Try resetting the compose method before -extent

convert img2.png img1.jpg -compose In -composite -compose over -background white -extent 0x0 +matte out.jpg

Re: Single combined command != multiple commands

Posted: 2012-11-20T12:05:33-07:00
by yoav.gonen
fmw42 wrote:
convert img2.png img1.jpg -compose In -composite -background white -extent 0x0 +matte out.jpg
Try resetting the compose method before -extent

convert img2.png img1.jpg -compose In -composite -compose over -background white -extent 0x0 +matte out.jpg
Hey, that worked! Thanks!