PNGOUT Tutorial

PNGOUT is a tool which can optimize PNG files created by other programs. It can be run from the Windows Run dialog box or at the command prompt. PNGOUT can produce even smaller files than pngcrush -brute or optipng -o7, however, since PNGOUT does not automate trials, you will have to find the right options yourself (Note: PNGOUTWin supports trials). Here is a list of command line options that affect compression ratio:

  • /c# : select the color type: {0,2,3,4,6}
  • /f# : select the filter type: {0,1,2,3,4,5,6}
  • /d# : select the color bit depth: {0(minimize),1,2,4,8}
  • /s# : select strategy: {0(default),1,2,3,4}
  • /k# : keep or remove ancillary (optional) chunks. (See description later)

Advanced options:

  • /b# : select the "block split threshold". This value is used by the special compression algorithm that PNGOUT uses. Different values can save a few bytes, although the default value is usually pretty good.
  • /n# : explicitly specify the number of block splits to use. This option overrides /b#.
  • /r : compress using randomized initial Huffman tables, which can affect the output size by a very small amount. Useful for running many trials with the same options.
  • /mincodes# : ensure Huffman tables have a minimum number of codes: {0(default),1,2}. May add a few extra bytes to the file size, but provides compatibility with buggy PNG decoders; applications using Zlib 1.2.1 require 1, while some mobile phones require 2.

The purpose of PNGOUT is to optimize files created by other image tools. It is not designed to duplicate their functionality. These are the limitations:

  • It won't convert an image to a color type or bit depth that cannot losslessly store the image.
  • It won't reduce the number of colors being used in an image, or convert the colors to grayscale unless all the colors correspond to PNG grayscale values already.
  • It won't remove alpha information from a PNG file.
  • PNG files with 16-bit color depths (48-bit or 64-bit pixels) are not supported.
  • Interlaced images are output as non-interlaced.
  • There is no batch processing mode.

Using the Run dialog box

Download PNGOUT from:

Ken Silverman's Utility Page.

Color options: /c#

/c4grayscale + alpha
/c6RGB + alpha
/c1 & /c5 are not valid

The number codes are from the official PNG specification.

If no /c# option is specified, PNGOUT will choose the color type that can most efficiently store the image. For example, if the input file uses 256 or fewer distinct colors, PNGOUT will choose the palette color type (/c3) to compress the image. For palette and grayscale images (/c0, /c3), it will use the minimum bit depth needed to store the image (/d0). Using the /c# and /d# options lets you override the default behavior.

Input file types:

PNGAll types supported except the rarely used 16-bit color depths.
GIFFull support. (Extracts first frame of animations)
BMPAll uncompressed BMP formats are supported.
JPGFull support.
TGAFull support.
PCXSupports 8 and 24 bit PCX

Input file names are not case sensitive. The .png extension can be omitted from PNG filenames both for input and output.

Windows clipboard option: /i

If the Windows clipboard contains a bitmap image you can add /i to the command line to use it as the input. Then you only need to specify the output filename.

Filter options: /f#

/f1Sub (delta x)
/f2Up (delta y)
/f3Average (delta x&y)
/f5Adaptive (mixed)
/f6Reuse (copy line by line from source PNG)

For palette images /f0 is best, and /f5 is often the best for grayscale or true color images, but not always. The default value is /f0 for palette images (/c3), and /f5 for everything else.

Strategy options: /s#

/s0Xtreme! (Slowest)
/s1Intense (Slow)
/s2Longest Match (Fast)
/s3Huffman Only (Faster)
/s4Uncompressed (Fastest)

The default method is Xtreme (/s0). It takes the most time to finish, but in most cases it achieves the best results.

PNGOUT.EXE exit codes: (for advanced users - i.e. batch files)

0Wrote file
1File error
2Unable to compress further
3Bad options

Other options:

/k0Remove all unnecessary chunks. (default)
/k1Keep all chunks.
/kCHUNKKeep only the named optional chunk(s). Chunk names are case sensitive. Invalid chunk names will be ignored. More than one chunk type can be preserved if you create a comma separated list: /kbKGD,tEXt,gAMA,pHYs
/kpKeep the palette order intact. Using this may hurt compression slightly, but it may be necessary for certain applications (often on small electronic devices) that need to share a common palette.
/ksKeep the settings (/c, /d, /f, /n) that were originally used to save the input file. This is set by default for files that were previously compressed by PNGOUT, but in either case the settings can be overridden with other command line parameters.
/ktKeep the file's original date and time. By default, the file's date and time will be replaced with the current time.
/vVerbose mode: list chunks to keep and remove. It also lists the /b# block boundaries and records the file length at each stage of the algorithm.
/qQuiet mode. Don't display any output.
/l (/L)List mode. Displays autodetected options from input file then quits before doing compression. May be helpful for batch optimizers.
/yAssume Yes at the 'overwrite file?' prompt. This is useful if you intend to run PNGOUT from a script.
/forceWrite file even if bigger. By default, PNGOUT will not overwrite a PNG file if it was not able to compress it further.

This PNGOUT tutorial was originally written by Kerry Watson, with updates by Ken Silverman and Matthew Fearnley

Last updated: 06/21/2009