By Xah Lee. Date: . Last updated: .


typical usage:

# optimize one file
oxipng -o 4 --strip safe filename.png

# optimize all png files in a dir
oxipng -o 4 --strip safe *.png

oxipng -h for help

oxipng 8.0.0
Joshua Holmer <jholmer.in@gmail.com>
Losslessly improves compression of PNG files

    oxipng.exe [OPTIONS] <files>...

    <files>...    File(s) to compress (use "-" for stdin)

    -o, --opt <level>          Optimization level - Default: 2 [possible values: 0, 1, 2, 3, 4, 5,
                               6, max]
    -b, --backup               Back up modified files
    -r, --recursive            Recurse into subdirectories
        --dir <directory>      Write output file(s) to <directory>
        --out <file>           Write output file to <file>
        --stdout               Write output to stdout
    -p, --preserve             Preserve file attributes if possible
    -c, --check                Do not run any optimization passes
    -P, --pretend              Do not write any files, only calculate compression gains
    -s                         Strip safely-removable metadata objects
        --strip <mode>         Strip metadata objects ['safe', 'all', or comma-separated list]
        --keep <list>          Strip all optional metadata except objects in the comma-separated
    -a, --alpha                Perform additional alpha optimizations
    -i, --interlace <0/1>      PNG interlace type [possible values: 0, 1]
    -v, --verbose              Run in verbose mode
    -q, --quiet                Run in quiet mode
    -f, --filters <filters>    PNG delta filters (0-9) - Default: 0,5
        --fast                 Use fast filter evaluation
        --zc <level>           zlib compression level (1-12) - Default: 11
        --nb                   No bit depth reduction
        --nc                   No color type reduction
        --np                   No palette reduction
        --ng                   No grayscale reduction
        --nx                   No reductions
        --nz                   No IDAT recoding unless necessary
        --fix                  Enable error recovery
        --force                Write the output even if it is larger than the input
    -Z, --zopfli               Use the slower but better compressing Zopfli algorithm
        --timeout <secs>       Maximum amount of time, in seconds, to spend on optimizations
    -t, --threads <num>        Set number of threads to use - default 1.5x CPU cores
    -h, --help                 Print help information
    -V, --version              Print version information

Optimization levels:
    -o 0   =>  --zc 5 --fast                (1 trial, determined heuristically)
    -o 1   =>  --zc 10 --fast               (1 trial, determined heuristically)
    -o 2   =>  --zc 11 -f 0,1,6,7 --fast    (1 trial, determined by fast evaluation)
    -o 3   =>  --zc 11 -f 0,7,8,9           (4 trials)
    -o 4   =>  --zc 12 -f 0,7,8,9           (4 trials; same as `-o 3` for zopfli)
    -o 5   =>  --zc 12 -f 0,1,2,5,6,7,8,9   (8 trials)
    -o 6   =>  --zc 12 -f 0-9               (10 trials)
    -o max =>                               (stable alias for the max compression)

    Manually specifying a compression option (zc, f, etc.) will override the optimization preset,
    regardless of the order you write the arguments.

PNG delta filters:
    0  =>  None
    1  =>  Sub
    2  =>  Up
    3  =>  Average
    4  =>  Paeth
Heuristic filter selection strategies:
    5  =>  MinSum    Minimum sum of absolute differences
    6  =>  Entropy   Highest Shannon entropy
    7  =>  Bigrams   Lowest count of distinct bigrams
    8  =>  BigEnt    Highest Shannon entropy of bigrams
    9  =>  Brute     Smallest compressed size (slow)

optimize png files

Just optimized 6751 png files on my sites. They were already optimized by optipng. Most files is about 5% to 10% decrease in size.

xah sites png 2023-02-10 5kFKx
xah sites png 2023-02-10 5kFKx
oxipng xahlee 2023-02-10 RhtbD
oxipng xahlee 2023-02-10 RhtbD
xahlee site png git 2023-02-10 QGxtF
xahlee site png git 2023-02-10 QGxtF

Image Tools