Find all your DIY electronics in the MakerShed. 3D Printing, Kits, Arduino, Raspberry Pi, Books & more!
png8 20090323 pngquant and pngnq   alpha PNG 8 images from the command line

For a long time, I’ve been using Fireworks for the sole task of creating 8-bit PNG images that will display alpha transparency correctly in all modern browsers, while degrading gracefully to a GIF-like binary transparency on older browsers. The process works well, but it’s sort of crazy to keep a second image editing application around just to save one specific image format.

Thankfully, there’s a command line tool called pngquant that will convert any PNG-24 image into an alpha PNG-8. Web designer Ethan Gardner put together a decent howto that demonstrates how to use it along with Photoshop. You should be able to do the same with GIMP or your image editor of choice. Just save the original as a 24-bit PNG, then run pngquant 256 [filename.png] from the command line.

There’s a similar program called pngnq which uses a different technique for quantizing images (taking a 24-bit image and reducing it to 256 colors). I started using this a little while ago and I’ve been pretty happy with the quality of the images produced. Similar to pngquant, just type pngnq -n 256 [filename.png] at the command line to produce an 8-bit alpha PNG from the 24-bit version. I’d recommend installing both–just pick the one that produces the better output for a given image.

Alpha Transparency in PNG-8 Images Without Using Fireworks
pngquant
pngnq


Related
blog comments powered by Disqus

Related Supplies at Maker Shed

Follow

Get every new post delivered to your Inbox.

Join 26,147 other followers