Page 1 of 1
Reduce PNG color depth for use in icons
Posted: 2011-10-07T23:06:15-07:00
by Rapisho
I need to reduce the color depth of some PNGs from 32bit to 8bit/256 colors and 4bit/16colors.
I've allready searched in the usage pages, but since my english skills are not the best and I use IM for the first time I only found these three usefull commands:
1.
Code: Select all
convert -colors 256 -depth 8 +dither image32.png image8.png
2.
Code: Select all
convert -colors 256 -depth 8 +dither -define png:color-type=3 image32.png image8.png
3.
Code: Select all
convert -colors 256 -depth 8 +dither -define png:color-type=3 -alpha Background image32.png image8.png
Here are the PNGs
1.
(the preview is not shown correctly, you have to klick on it to see the transparency)
2.
3.
original 32bit
(also not shown correctly, just follow the link)
If I load the 1. Image in my icon creation tool, Axialis IconWorkshop, it looks exactly as the 2. , everything transparent gets black.
I think what I need is something like the second image only with transparent background or transparent background with dither like in this image
http://www.imagemagick.org/Usage/quanti ... ome_fs.gif if its possible for PNG.
Would be very thankful for getting some help.
Re: Reduce PNG color depth for use in icons
Posted: 2011-10-08T01:31:53-07:00
by Bonzo
Your first comand worked for me and changed to a 8 bit png from a 32bit.
I changed the comand around as well as the input image should be read in first.
Code: Select all
convert 1.png -colors 256 -depth 8 +dither image8.png
What version are you using?
Note: Not impressed with your image hosting site.
Re: Reduce PNG color depth for use in icons
Posted: 2011-10-08T02:12:59-07:00
by Rapisho
I use the most recent version for windows on win 7.
The commend worked for me too, Irfanview shows the transparency and bit depth correctly. So I think IconWorkshop causes the problem, but I hoped theres a special option to use during conversion.
€: I have antoher idea. Which picture format support transparency with 8bit except png and gif? Gif doesn't work too.
Re: Reduce PNG color depth for use in icons
Posted: 2011-10-08T05:58:46-07:00
by glennrp
If you can accept binary transparency, try
Code: Select all
convert -colors 256 -depth 8 +dither image32.png png8:image8.png
Re: Reduce PNG color depth for use in icons
Posted: 2011-10-08T06:09:15-07:00
by glennrp
If you can accept binary transparency, try
Code: Select all
convert -colors 256 +dither image32.png png8:image8.png
convert -colors 16 +dither image8.png image4.png
Re: Reduce PNG color depth for use in icons
Posted: 2011-10-08T07:12:43-07:00
by Rapisho
Thank you so much! I've allready capitulated.
The png8: worked fine, the 4bit PNGs still use their transparency. I think IconWorkshop accepts only binary transparency.
Is possible to apply this to the 4 bit conversion? Or is this allready done with " -colors 16" ? In fact its not that important as it is for 8bit, but it still would be nice.
Re: Reduce PNG color depth for use in icons
Posted: 2011-10-08T07:27:48-07:00
by glennrp
Rapisho wrote:Thank you so much! I've allready capitulated.
The png8: worked fine, the 4bit PNGs still use their transparency. I think IconWorkshop accepts only binary transparency.
Is possible to apply this to the 4 bit conversion? Or is this allready done with " -colors 16" ? In fact its not that important as it is for 8bit, but it still would be nice.
That's why I did the 4-bit in two steps: first png8 then convert that to 16 colors (4-bit). The conversion to png8, among other things, reduces the transparency to binary. You could do that by other means such as ordered-dither of the alpha channel (the png8 conversion just does a simple 50% threshold on the alpha channel). BTW, my image4.png looks transparent to me.
Re: Reduce PNG color depth for use in icons
Posted: 2011-10-08T08:31:04-07:00
by Rapisho
Sorry I didn't recognize the different file names and thought you did kind of a double post, but it still doesn't work with those both.
How do I change the threshold manually? Theres a black border at the bottom of the image. (its the 8bit version)
Re: Reduce PNG color depth for use in icons
Posted: 2011-10-08T11:57:13-07:00
by glennrp
Rapisho wrote:How do I change the threshold manually?
Code: Select all
convert -channel A -threshold 10% ...
Re: Reduce PNG color depth for use in icons
Posted: 2011-10-09T03:34:21-07:00
by Rapisho
Thx, worked.
Only one last thing. Some of the icons have more parts with transparency than the shadow, like this:
If I convert it with
Code: Select all
convert -colors 256 -depth 8 +dither -channel A -threshold 46%% image32.png png8:image8.png
this is the result:
I guess its because that what appears grey is black with alpha. Can I still get it grey after conversion without affecting the shadow?
Re: Reduce PNG color depth for use in icons
Posted: 2011-10-10T06:21:41-07:00
by glennrp
You could ordered-dither the alpha channel instead of thresholding it, but
I think just letting the dark grey become black is cleaner.
Code: Select all
convert -colors 256 -depth 8 +dither -channel A -ordered-dither 2x2 image32.png image8.png
Otherwise you could transform the particular 60%-alpha black pixels to grey-opaque ones manually
before doing the reduction, but that would be a particular operation for this specific image, not a general
solution.