I have two same-size png files, A.png and B.png.
Each has a white background, a black grid pattern, and some black dots.
The black dots are in different places in each image.
I want to overlay A on B, so that the result shows the dots in both A and B,
along with the grid pattern.
On a Linux box with ImageMagick 6.5.1-2 2010-01-06 Q16 OpenMP,
I do this successfully with
convert -composite -transparent white A.png B.png C.png
C.png is the result I want.
I have posted the plots online at: http://www.srl.caltech.edu/NuSTAR_Public/ad/
However, on another Linux box with ImageMagick 6.6.5-10 2011-02-08 Q16,
the result using the same command is an image with a completely black background,
and the grid-pattern has turned blue.
See C_bad.png on the website.
Can someone help me get the result I want, using ImageMagick 6.6.5-10 2011-02-08 Q16 ?
I've tried many permutations of arguments to the convert and composite commands, with no luck...
Thanks,
Andrew
composite image woes with newer ImageMagick version
Re: composite image woes with newer ImageMagick version
Try the following command
convert -composite -transparent white A.png B.png -flatten +matte C.png
convert -composite -transparent white A.png B.png -flatten +matte C.png
Re: composite image woes with newer ImageMagick version
Thanks dirk1976, that works!
And it works on the older ImageMagick version also, another plus.
Cheers
And it works on the older ImageMagick version also, another plus.
Cheers
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: composite image woes with newer ImageMagick version
PNG has undergone quite a few changes over many releases and may have had some bugs along the way.
However, your syntax is not proper IM 6 syntax, though may still work. The images should be read first. I assume you are trying to composite the two images together and then make the result have transparency where it was white. If that is not the case, then please clarify what you are trying to do.
convert A.png B.png -composite -transparent white C.png
On the other hand if you want to make the two images have white become transparent before compositing them, then
convert A.png B.png -transparent white -composite C.png
see
http://www.imagemagick.org/Usage/basics/#why
http://www.imagemagick.org/Usage/layers/
However, your syntax is not proper IM 6 syntax, though may still work. The images should be read first. I assume you are trying to composite the two images together and then make the result have transparency where it was white. If that is not the case, then please clarify what you are trying to do.
convert A.png B.png -composite -transparent white C.png
On the other hand if you want to make the two images have white become transparent before compositing them, then
convert A.png B.png -transparent white -composite C.png
see
http://www.imagemagick.org/Usage/basics/#why
http://www.imagemagick.org/Usage/layers/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: composite image woes with newer ImageMagick version
That command is completely non-sensical. the options are operations that get applied in the order given, and you are trying to compose images BEFORE they are read, invoking legacy option handling. You also do two composition methods for just two input images, and replace pure white in the first image with transparency, forgetting that images may be grayscale, and not simply pure black and white.dirk1976 wrote:Try the following commandgCode: Select all
convert -composite -transparent white A.png B.png -flatten +matte C.pn
I strongly suggest you read IM examples Basics!
http://www.imagemagick.org/Usage/basics/
UPDATE: added to the above... IMv6 syntax...
http://www.imagemagick.org/Usage/basics/#syntax
This means the IMv6 syntax can now be simplified as being...With the part in {...} being repeated with as many 'reads' or 'operations' you want or need, to process your images in the exact order required.Code: Select all
command { [-setting]... "image"|-operation }... "output_image"
As the background of the images is white, and you want to preserve black, why not multiply the images. Anything black in either image becomes black in the result.
Code: Select all
convert A.png B.png -compose multiply -composite C.png
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/