I have a series of PNG images with transparent backgrounds that I want to overlay onto a destination PNG image that also has a transparent background. For argument sake let's say that the series of images are :
Since I want to overlay all the images at once, I am going to use the convert
command, with the compose
switch as follows :
gm convert -compose Atop dest.png img1.png img2.png img3.png -flatten output.png
Seems simple enough, but the problem is that output.png looses it's transparency and I do not know how to keep it enabled. If I use the -background
switch I can set what used to be the transparency to any color I want, but I cannot get it to go back to transparency.
Yes, I can subsequently call:
gm convert -transparency black ouput.png output2.png
but then any black on the actual image becomes transparent as well.
Any help here?
I faced the same issue, and I did a couple things to get it to work.
You should get what you want if you change your command to:
gm convert xc:transparent -compose Over img1.png img2.png img3.png -mosaic dest.png
You may want to use Atop
of Over
depending on the functionality you want out of the compose method.
Using mosaic
instead of flatten
combined with the xc:transparent
argument caused it to keep their transparencies and produces an image with transparencies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With