Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image Magick preserve transparency

I an trying to use Image Magick to create a new large png from several small png's but the smaller image do not have their transparency preserved. I am creating a 6000x6000 image and placing smaller png's at specific locations and some of them being rotated, this all works fine. The problem is that the small images don't have their transparency preserved when some of the small image overlap. This is an example of what I mean. I have tried several -channel options and -alpha on but nothing seems to work. What am i missing here?

enter image description here

Here is the commands I am using for my test.

convert -size 6000x6000 xc:none ^
    ( Rectangle_01.png -repage +200+200 ) ^
    ( Rectangle_01.png -repage +651+200 -rotate 45 ) ^
    ( Rectangle_01.png -repage +1102+200 -rotate -45 ) -flatten -alpha on test.png
like image 266
Trevor Orr Avatar asked Apr 07 '14 20:04

Trevor Orr


2 Answers

Did you try:

-background none

none is one of the built-in color names for a fully transparent color.

I found this question when trying to solve a similar problem with the montage command, that would not preserve transparency. Setting a transparent background did fix my problem. The default background in ImageMagick is white.

like image 135
François Avatar answered Nov 23 '22 18:11

François


There is a similar topic on http://www.imagemagick.org

"Try:

-fuzz XX% -transparent white

where the smaller the %, the closer to true white or conversely, the larger the %, the more variation from white is allowed to become transparent."

http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=12619

like image 25
almanegra Avatar answered Nov 23 '22 18:11

almanegra