Page 1 of 1

Apply Color Map To PNG w/Alpha Channel

Posted: 2010-07-17T21:48:07-07:00
by bcgreen24
I'm using the following command to apply a color map to an image:

/usr/bin/convert ./uploads/logoshrunk.png +dither -map mymap.png ./uploads/logoindexed.png

It works just fine-- unless the PNG has an alpha channel. When this is the case, the transparent areas are rendered as black. Is this a bug, or am I doing something horribly wrong?

Thanks!
Bryan

Re: Apply Color Map To PNG w/Alpha Channel

Posted: 2010-07-18T07:46:43-07:00
by Drarakel
It's a bug (at least if you have only simple binary transparency). Indexed PNGs can't handle transparency correctly at the moment. Meanwhile, add "-type TrueColorMatte" to your command - with that, a correct (PNG32) file should get written.

Re: Apply Color Map To PNG w/Alpha Channel

Posted: 2010-07-19T02:17:21-07:00
by anthony
Does the mymap.png file have any transparent colors in it?

Re: Apply Color Map To PNG w/Alpha Channel

Posted: 2010-07-19T09:38:10-07:00
by bcgreen24
Nope, the 'mymap.png' image that I'm using as a color map does not contain any transparency.

Drarakel-- thanks for the heads-up; I'll give it a try and see what happens.

Bryan

Re: Apply Color Map To PNG w/Alpha Channel

Posted: 2010-07-19T20:30:19-07:00
by bcgreen24
The "-type TrueColorMatte" option isn't working...

Bryan

Re: Apply Color Map To PNG w/Alpha Channel

Posted: 2010-07-19T20:33:28-07:00
by fmw42
Try adding

-colorspace rgba -matte

to your command and see if that helps. Put it right after your input image.

Also if your colormap does not have any transparent colors then you are mapping an image with transparency to one that does not, if I am not mistaken.

You can also try

convert image -alpha off -map colormap -alpha on result

that may turn off the transparent channel, do the mapping, and then turn your original alpha channel back on.

I am not really sure I know what you expect to happen with the transparent colors in your original image when you have a color map with no transparency. So I am not sure what really makes sense to suggest.

Re: Apply Color Map To PNG w/Alpha Channel

Posted: 2010-07-19T20:48:38-07:00
by bcgreen24
Hmmm...I took the client's color map and added a transparent section to it-- still didn't work.

I'll try the suggestions above and see what happens..thank you all so much for your efforts. It is VERY much appreciated.

============================================
***UPDATE***
I don't know why it didn't work before, but I took the original color map and added a little transparent block to it, and now the color mapping is working exactly as I wanted it to in the first place. So there is no bug-- I just stupidly hadn't included a transparent section in the PNG I was using as a color map.

Thanks all!!!

Bryan
=============================================

Re: Apply Color Map To PNG w/Alpha Channel

Posted: 2010-07-20T19:38:40-07:00
by anthony
Try using -quantize transparent which treels the color dither to ignore transparency in the image when assigning colors.