png transparency when overlaying two images

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
chainas

png transparency when overlaying two images

Post by chainas »

Hello,

i tried to find similar problem using search, but no exact results found. So i will try to explain my problem.

Image one (background): Image

Image two (image over background): Image

Expected result (overlayed image): Image

I made it local in my cmd (on windows) with this command:

Code: Select all

composite -geometry +60+40 manutd.png bg.jpg overlayed.jpg
But when i try to do this command in my symfony php sfImageMagickAdapter class file, i getting black background of manutd.png image.

So my question is, maybe there are some additional overlaying parameters to overlay those images more correclty ?

Thanks for answers
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: png transparency when overlaying two images

Post by Bonzo »

Some examples here:
http://www.rubblewebs.co.uk/imagemagick ... ompose.php
More detail here:
http://www.imagemagick.org/Usage/compose/

You should use -gravity with -geometry:

Code: Select all

composite manutd.png bg.jpg -gravity northwest -geometry +60+40  overlayed.jpg
chainas

Re: png transparency when overlaying two images

Post by chainas »

I tried Your suggestions, but still no result.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: png transparency when overlaying two images

Post by Bonzo »

You can use convert as well:

Code: Select all

convert bg.jpg manutd.png -gravity northwest -geometry +60+40 -composite overlayed.jpg
Note the order of images changes.
chainas

Re: png transparency when overlaying two images

Post by chainas »

Yeach, but still no result. Maybe i need to remove somehow the background of png image before overlaying ?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: png transparency when overlaying two images

Post by Bonzo »

I used your images and they worked OK.

When you run this from the command prompt do you get a rw- next to png, png24, png32 and png8

Code: Select all

convert -list Format
Post Reply