Exporting PNG8 images with alpha transparency on macOS

I used to use ImageAlpha to convert transparent PNGs to PNG8 with alpha transparency. For images with limited colors, this often results in a drastically smaller file size with very little loss in quality, especially if the dithering is done well. In the example below, the final image is 24% of the size of the original—just 61 KB rather than 258 KB. Unfortunately ImageAlpha doesn’t work in recent versions of macOS, as it relies on Python 2. I’ve spent a good amount of time searching for an alternative.

The original image, in PNG24 format, with alpha transparency. The file size is 258 KB.

Adobe Photoshop can’t create a PNG8 file with alpha transparency as far as I can tell. This SuperUser post says otherwise, but when I use “Export As” with the “Smaller File (8-bit)” option checked, pixels are either fully transparent or fully opaque. In some cases this may be fine, but it’s not much different from using a GIF. Alpha transparency allows for partially transparent pixels, for effects like the shadow on the image above.

Photoshop’s “Save for Web (Legacy)” does not fare any better.

Photoshop’s attempt. The file size is a compact 82 KB, but the alpha transparency is lost.

If you don’t mind using the command line, pngquant can create images in the correct format. I generally don’t mind using the command line or writing my own scripts, but sometimes it’s nice to just download a nice GUI app and get your work done.

I finally found Pngyu, a nice GUI app that’s similar in functionality to what ImageAlpha offered. Just like ImageAlpha, it uses pngquant to do the actual work. The UI is a bit clunky, and it did crash one of the times I’ve used it, but not without successfully completing the job first.

Pngyu’s result. The file size is a mere 61 KB when combined with ImageOptim, and the transparency is correct.
Posted September 11th, 2023 by Mike Piontek
Link to this entry: https://mikepiontek.com/go/9264

More recent posts