Convert 24-bit images into smaller and optimized 8-bit PNG files.

Overview

On the web, GIF was in prime position for many years when it came to small files with indexed colors. It was soon followed by PNG, which supports both 24-bit and 8-bit. While in this image file format, the 24-bit file is lossless compressed and therefore similar to TIFF files it is also relatively large, the 8-bit version results in smaller file sizes by reducing the color palette and clever dithering. The censhare image services now come with the tool pngquant which will be used to calculate appealing and compact 8-bit PNGs. The difference is often only recognized when you are very close to the screen or zoom into the image.

Original size, left: 24-bit original PNG. Centre: dithered 8-bit version with pngquant. Right: 8-bit reduction without pngquant - Download comparison in full size

Example

Your PNG file (24-bit) is 5 MB. To render its file size smaller, use the option pngquant of censhare's image service. When the check-box "Indexed color" is set for the PNG format in an image module, ImageMagick passes the result to the command-line tool pngquant. The almost imperceptible reduction of the color depth to 8-bit is achieved through a dithering algorithm (Floyd-Steinberg)

and the size of the resulting file shrinks, ideally to about 20% of its original file size.

Configuration

censhare image service comes can produce PNG files with indexed colors.

After the 3rd party tool pngquant is installed and configured, the subjective perception of the image of the result is indistinguishable from the original image. The file size is reduced on average to 1/ 5 of the original. Transparency and translucency are retained.

The installation target of pngquant can be the corpus/tools directory on the server or locally, but then a Service-Client has to do the work. However, pngquant is not currently available or planned for Solaris. 

For more information, see this information and downloads for OS X/Linux.

Since /opt/corpus/tools/pngquant/bin/pngquant is already the default path, it will be most convenient to unpack and install pngquant therein on your server or the host system of the Service-Client.

Commands that offer a UI configuration option in the Admin Client:

  • Modules/Image/Convert image, which also applies to the automatic variant of the action.

  • Modules/Image/Create additional image, which also applies to the automatic variant of the action.

Settings: Create additional image


Settings: Convert image


Tick the "Indexed Color" checkbox to perform an 8-bit optimization with pngquant. The indexed 8-bit files always output at 72 dpi, even if you have entered a higher resolution.

Note:

With existing installations of the Service-Client, the server over time may tend to stop accepting the new preferences. If this occurs, the following radical action is necessary:

cd /Users/username/Library/Preferences/v4/rm service*       
cd hosts/myhost/rm service*
CODE

After that, you now need to update the server configuration and restart the Service-Client.

With pngquant, you can achieve the best quality results. However, if no pngquant is available, the indexed color palette is only generated by ImageMagick as a fallback and is evident because of the posterization effect and the resulting poor image quality. The optional parameters of pngquant are not used by censhare, so there is only a predefined setting that achieves a good compromise between image quality and image size.

Image variants via XSLT

Service-Client running with an installation of pngquant on macOS X