INSTALL 2.55 KB
Newer Older
1 2 3 4 5 6
## Compiling on Linux, *BSD and macOS

(For instructions for Windows see section below.)

### Using GNU/Makefile

7 8
To get the code:

9 10 11 12
    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`.
13

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

16
    make
17

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

21
    sudo make install
22 23

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

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

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

31
### Using Rust/Cargo
32

33
If you have Rust, you can also build with `cargo build`.
34

35
### Custom static libpng
36

37 38 39
Extract libpng source code as a *sub*directory of pngquant source directory.
Build static libpng (`./configure --enable-static && make`), and then
`./configure && make` pngquant.
40

41
When building with Cargo, `export PNG_STATIC=1`.
42

43 44 45 46 47 48 49 50 51 52
## Windows

Compiling on Windows is supported only via Rust/Cargo.

 1. Install git (msys-git).
 2. Install Visual C++ 2015 Build Tools.
 3. [Install Rust](https://www.rust-lang.org/install.html)
 4. Restart Windows.

Open Git's Bash prompt and run:
53

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
    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 `pngquant.exe` in `target/release` subfolder.

## Compilation with OpenMP

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

71
## Compilation without Cocoa image reader
72

73 74
macOS version can use Cocoa to read images. This adds support for color profiles
and other image formats as input.
75

76
    cargo build --release --features=cocoa
77

78
## Compilation with Little CMS 2
79

80
Little CMS library is used by default.
81

82 83
It's linked dynamically if `pkg-config` is working (e.g. install `liblcms2-dev`).
Otherwise uses static build as a fallback.
84

85
Set `export LCMS2_STATIC=1` to force static linking.
86

87
## Compilation of `libimagequant.a` only
88 89

If you want to use pngquant's conversion algorithm without loading/saving PNG
90
files, then you can run `make` or `cargo build` in the `lib/` directory.
91

92
The library doesn't need libpng nor zlib.