Overlay an image with transparency

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
splitbrain
Posts: 2
Joined: 2012-03-10T13:47:58-07:00
Authentication code: 8675308

Overlay an image with transparency

Post by splitbrain »

Hi,

I have this image http://i.imgur.com/aQeyj.png and want to overlay this image http://i.imgur.com/FhDDb.png to color every second icon. As you can see, both images have transparent backgrounds.

After reading these forums and a lot of trial and error I came up with this code:

Code: Select all

convert $TEMP/darkicons.png $TEMP/activemask.png  \
\( -clone 0 -alpha extract \) \
\( -clone 0 -clone 1 -compose overlay -composite \) \
-delete 0,1 +swap -alpha off -compose copy_opacity -composite $OUT/sprite.png
It somewhat works: http://i.imgur.com/qIukE.png

But if you look closely the colored icons look much more washed out than it's gray counterparts. The reason seems to be that the Alpha-Channel is much sharper defined in the original than in the colored versions. Here's a screenshot of the Alpha-Channel I made in Gimp (zoomed in): http://i.imgur.com/9PbTJ.png

So I guess my question is, how do I color the icons without loosing the sharpness or the transparent background?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Overlay an image with transparency

Post by fmw42 »

They do not looked washed out to me. Perhaps I am missing something, but they look fine. Can you show an example of what you want it to look like?
splitbrain
Posts: 2
Joined: 2012-03-10T13:47:58-07:00
Authentication code: 8675308

Re: Overlay an image with transparency

Post by splitbrain »

I solved the problem by writing a script in libGD and PHP instead.
Post Reply