Single combined command != multiple commands

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
yoav.gonen
Posts: 5
Joined: 2012-05-02T04:25:35-07:00
Authentication code: 13

Single combined command != multiple commands

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Single combined command != multiple commands

Post 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
yoav.gonen
Posts: 5
Joined: 2012-05-02T04:25:35-07:00
Authentication code: 13

Re: Single combined command != multiple commands

Post 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!
Post Reply