Page 1 of 1

Overlay an image with transparency

Posted: 2012-03-10T15:46:07-07:00
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?

Re: Overlay an image with transparency

Posted: 2012-03-10T16:27:11-07:00
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?

Re: Overlay an image with transparency

Posted: 2012-03-11T02:53:17-07:00
by splitbrain
I solved the problem by writing a script in libGD and PHP instead.