Page 1 of 1

Convert PNG32 to PNG8 with alpha transparency

Posted: 2007-10-01T09:40:11-07:00
by whoisgregg
Hello,

I have over 200,000 images stored as transparent PNGs. I need to convert each to an alpha transparent, grayscale PNG. The settings of this PNG must match a specific format to be compatible with a GD and ImageMagick driven system.

Right now, I can't seem to get the right kind of output to match what I can produce out of Fireworks. I have also posted test cases including sample files. I've tried dozens of variations to achieve my goal but none of them are right. :(

Also, you can download the sample files directly:
Sample Original File
Desired Output File

Basically, I want to duplicate these export settings from Fireworks:
Image

I can get the conversion to an alpha transparent grayscale. But I can't get PNG 8 output to work with alpha transparency. And it seems there should be a more elegant method than building all these intermediate images... :(

Code: Select all

 convert -size 634x668 xc:white -matte white.png
convert -size 634x668 xc:black -matte black.png
convert \( original.png -quantize GRAY -colors 256 \) grayed.png
composite -compose Dst_Over white.png grayed.png grayed_flat.png
convert black.png \( grayed_flat.png -negate \) +matte -compose Copy_Opacity -composite -depth 8 -colors 16 composite_copy_opacity.png
Any ideas anyone can recommend are much appreciated. Thanks! :)

Re: Convert PNG32 to PNG8 with alpha transparency

Posted: 2007-10-01T14:08:39-07:00
by whoisgregg
I have installed and tried pngcrush, optipng, and pngout in an effort to find a command line tool that can convert to a PNG8 with alpha transparency.

No luck with any of them until I used pngout. I have a test case working using this call:

Code: Select all

pngout-darwin -c3 -d8 original.png pngout.png
-c3 means "palette" and -d8 refers to color depth. Good luck so far but it's dead slow. I'll be tweaking settings to get it faster but wanted to post back with my progress. :)