pngquant Installation

Compiling on Linux, *BSD and macOS

(For instructions for Windows see section below.)

To get the code:

git clone --recursive https://github.com/pornel/pngquant.git

You will need libpng installed with development headers. On Linux install libpng-dev package. On macOS brew install libpng.

make

It will create pngquant executable in the current directory. If you'd like to install it system-wide:

sudo make install

By default it will be installed in /usr/local/bin. To install it in another directory run ./configure --prefix=dir && make.

pngquant uses GNU Makefile. To compile on FreeBSD you will need to use gmake.

Avoid Linux distros that ship with libpng 1.2. It is old and buggy. Use libpng 1.6 or later.

Windows

Compiling on Windows is horrible. Please use pre-built binaries if possible.

Install git (msys-git). Install mingw or mingw64, depending on your OS version. Ensure system PATH environment variable to contains C:\mingw\bin.

Restart Windows.

Open Git's Bash prompt and run:

git clone -b msvc --recursive https://github.com/pornel/pngquant.git
cd pngquant

This will create pngquant folder in your user folder.

Download zlib source code 1.2 or later. Do not download a DLL-only version — it will not work.

Move the zlib-1.2.tar.gz archive to the pngquant folder and run:

tar xf zlib*gz
mv zlib-<press tab> zlib
cd zlib
make -f win32/Makefile.gcc
cd ..

if make doesn't work, try mingw32-make. If that doesn't work, fix your PATH.

Download libpng 1.6 or later, extract it as a subfolder of pngquant folder. Do not use pre-built libpng — it will not work.

Change current directory to the extracted libpng (ir will be "lpng168" or such)

cd lpng<press tab>
cp ../zlib/*.h ./
make -f scripts/makefile.msys ZLIBLIB=../zlib
cd ..
make

Ignore the compilation errors. Hopefully it'll work anyway. Good luck!

Compilation with OpenMP

./configure --with-openmp && make

On macOS you may need to install gcc and add CC=gcc-6 to ./configure, because clang doesn't support OpenMP (yet).

Compilation without Cocoa image reader

macOS version uses Cocoa to read images. This adds support for color profiles and other image formats as input. ./configure --without-cocoa switches back to libpng.

Compilation with Little CMS 2

./configure --with-lcms2 && make

Enables support for ICC v2/v4 color profiles when reading images. Requires Little CMS library available via pgk-config (e.g. install liblcms2-dev).

Compilation of libimagequant.a only

If you want to use pngquant's conversion algorithm without loading/saving PNG files, then you can run make in the lib/ directory. The library doesn't need libpng or zlib.

Return to home page.