Page 1 of 1

Merging transparency with a png

Posted: 2010-09-24T07:59:21-07:00
by dra
I have two 7x7 pixel PNG files. One contains a red triangle with the other half of the image being fully transparent white; the other image is totally opaque. I'm trying to create a 47x7 PNG which has the one image at the left and the other at the right with a similarly transparent white background. I've tried saying:

convert -size 47x7 xc:transparent Triangle.png -geometry +40+0 -composite 1.png -composite New.png

This gives me a 47x7 PNG with a transparent background with the image from 1.png on the left and the image from Triangle.png on the right. However, the transparent region from Triangle.png shows up in solid black. I've tried playing with the -alpha option (and tried reading lots of similar examples in the docs) but can't get it to copy the transparency through.

Any help much appreciated!

Re: Merging transparency with a png

Posted: 2010-09-24T09:45:27-07:00
by fmw42
try


convert -size 47x7 xc:none -gravity west Triangle.png -composite -gravity east 1.png -composite New.png

or

convert Triangle.png -size 33x7 xc:none 1.png +append New.png

If those don't work, then provide links to your two input images so we can see if they have any problems.

Re: Merging transparency with a png

Posted: 2010-09-25T01:49:38-07:00
by dra
Afraid that both of those actually put Triangle.png and 1.png the other way around and the transparency from Triangle.png still gets turned to black.

I've uploaded http://romulus.metastack.com/files/magick.zip which contains the two source files Triangle.png and 1.png, the result I'm getting with my command in New.png and also Required.png which is what I'm trying to get!

Re: Merging transparency with a png

Posted: 2010-09-25T09:57:15-07:00
by fmw42
These two commands work perfectly for me on IM 6.6.4.6 Q16 Mac OSX Tiger. No black showing from the Triangle.png image. Note I switched the images or the gravity settings to reverse the image order to get what you wanted.


convert -size 47x7 xc:none -gravity east Triangle.png -composite -gravity west 1.png -composite New1.png

convert 1.png -size 33x7 xc:none Triangle.png +append New2.png


What version of IM are you using? Perhaps you need to upgrade.

Re: Merging transparency with a png

Posted: 2010-09-26T02:40:48-07:00
by dra
:oops: How embarrassing - I was so convinced that it was simply that I was doing something wrong with a switch that I didn't consider it could be a bug and check for later versions - I was running 6.6.1 from when I built this machine in May... 6.6.4 works fine.

Thanks for the help!