pngquant Installation

Compiling on Linux, *BSD and macOS

(For instructions for Windows see section below.)

To get the code:

git clone --recursive

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

There's an optional ./configure step (see sections below). Run:


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.

If you have Rust, you can also build with cargo build.

Custom static libpng

Extract libpng source code as a subdirectory of pngquant source directory. Build static libpng (./configure --enable-static && make), and then ./configure && make pngquant.

When building with Cargo, export PNG_STATIC=1.


Compiling on Windows can be done in two ways: using Rust or using C toolchain.

Building with Rust's Cargo

This is the easiest option.

Install git (msys-git).

Install Visual C++ 2015 Build Tools.

Install Rust (

Restart Windows.

Open Git's Bash prompt and run:

git clone -b msvc --recursive
cd pngquant

This will create pngquant folder in your user folder. And then run:

cargo build --release

It will create pngquant.exe in target/release subfolder.

Building using C toolchain

It's going to be much harder. Please reconsider the Rust/Cargo option.

Install git (msys-git).

Install mingw64. Ensure system PATH environment variable contains C:\mingw64\bin.

Restart Windows.

Open Git's Bash prompt and run:

git clone -b msvc --recursive
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 ..

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).

When building with Cargo lcms2 is used by default. It's linked dynamically if pkg-config is working. Otherwise uses static build as a fallback. Set export LCMS2_STATIC=1 to force static linking in Cargo.

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 nor zlib.

Compilation with other versions of libimagequant

This is an advanced option for Linux distributions wishing to unbundle libimagequant.

Option --with-libimagequant makes ./configure query pkg-config for imagequant.

Additionally, --with-libimagequant=<dir> makes ./configure search in <dir>/lib for and <dir>/include for libimagequant.h.

./configure --with-libimagequant=/usr/local

Return to home page.