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

Technology
pngquant and pngnq – alpha PNG-8 images from the command-line
png8-20090323.png

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

What will the next generation of Make: look like? We’re inviting you to shape the future by investing in Make:. By becoming an investor, you help decide what’s next. The future of Make: is in your hands. Learn More.

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

ADVERTISEMENT

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

Prices Increase in....

Days
Hours
Minutes
Seconds
FEEDBACK