pngquant and pngnq – alpha PNG-8 images from the command-line

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

Discuss this article with the rest of the community on our Discord server!


Ready to dive into the realm of hands-on innovation? This collection serves as your passport to an exhilarating journey of cutting-edge tinkering and technological marvels, encompassing 15 indispensable books tailored for budding creators.

Escape to an island of imagination + innovation as Maker Faire Bay Area returns for its 15th iteration!

Buy Tickets today! SAVE 15% and lock-in your preferred date(s).