(For instructions for Windows see section below.)
To get the code:
git clone --recursive https://github.com/kornelski/pngquant.git
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
./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.
If you have Rust, you can also build with
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,
Compiling on Windows is supported only via Rust/Cargo.
Open Git's Bash prompt and run:
git clone -b msvc --recursive https://github.com/kornelski/pngquant.git cd pngquant
This will create pngquant folder in your user folder. And then run:
cargo build --release
It will create
cargo build --release --features=openmp # or cargo build --release --features=openmp-static
On macOS you may need to install gcc and run
export CC=gcc-7 first,
because clang doesn't support OpenMP (yet).
macOS version can use Cocoa to read images. This adds support for color profiles and other image formats as input.
cargo build --release --features=cocoa
Little CMS library is used by default.
It's linked dynamically if
pkg-config is working (e.g. install
Otherwise uses static build as a fallback.
export LCMS2_STATIC=1 to force static linking.
If you want to use pngquant's conversion algorithm without loading/saving PNG
files, then you can run
cargo build in the
The library doesn't need libpng nor zlib.
Return to home page.