(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.
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
./configure --prefix=dir && make.
pngquant uses GNU Makefile. To compile on FreeBSD you will need to use
Avoid Linux distros that ship with libpng 1.2. It is old and buggy. Use libpng 1.6 or later.
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
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 ..
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!
./configure --with-openmp && make
On macOS you may need to install gcc and add
because clang doesn't support OpenMP (yet).
macOS version uses Cocoa to read images. This adds support for color profiles
and other image formats as input.
./configure --without-cocoa switches back
./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
If you want to use pngquant's conversion algorithm without loading/saving PNG
files, then you can run
make in the
The library doesn't need libpng or zlib.
Return to home page.