CINXE.COM
PNGOUT Tutorial
<HTML><HEAD><TITLE>PNGOUT Tutorial</TITLE></HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000CC" ALINK="#0000FF" VLINK="#800080"> <TABLE CELLSPACING=0 CELLPADDING=13 WIDTH="100%"><TR> <TD VALIGN=top WIDTH="50%"> <H2>PNGOUT Tutorial</H2> <P>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 <I>pngcrush -brute</I> or <I>optipng -o7</I>, however, since PNGOUT does not automate trials, you will have to find the right options yourself (Note: <a href="http://ardfry.com/pngoutwin/">PNGOUTWin</a> supports trials). Here is a list of command line options that affect compression ratio:</P> <UL> <LI>/c# : select the color type: {0,2,3,4,6} <LI>/f# : select the filter type: {0,1,2,3,4,5,6} <LI>/d# : select the color bit depth: {0(minimize),1,2,4,8} <LI>/s# : select strategy: {0(default),1,2,3,4} <LI>/k# : keep or remove ancillary (optional) chunks. (See description later) </UL> <P>Advanced options:</P> <UL> <LI>/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. <LI>/n# : explicitly specify the number of block splits to use. This option overrides /b#. <LI>/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. <LI>/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. </UL> <P>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:</P> <UL> <LI>It won't convert an image to a color type or bit depth that cannot losslessly store the image. <LI>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. <LI>It won't remove alpha information from a PNG file. <LI>PNG files with 16-bit color depths (48-bit or 64-bit pixels) are not supported. <LI>Interlaced images are output as non-interlaced. <LI>There is no batch processing mode. </UL> </TD> <TD BGCOLOR="#F0F0F0" VALIGN=top ALIGN=center WIDTH="50%"> <H2>Using the Run dialog box</H2> <IMG SRC="run_dialog.png" width=380 height=295><BR> <H2>Download PNGOUT from:</H2> <P> <A HREF="http://advsys.net/ken/utils.htm#pngout"></A> <A HREF="http://advsys.net/ken/utils.htm#pngout">Ken Silverman's Utility Page</A>. </P> </TD></TR></TABLE> <TABLE CELLSPACING=0 CELLPADDING=13 WIDTH="100%"><TR> <TD BGCOLOR="#F0F0F0" VALIGN=top WIDTH="50%"> <H2>Color options: /c#</H2> <TABLE CELLSPACING=0 CELLPADDING=0><TR><TD BGCOLOR=gray> <TABLE CELLSPACING=1 CELLPADDING=6 WIDTH="100%"><TR> <TD BGCOLOR="#e0e0e0"><TT>/c0</TT></TD><TD BGCOLOR="#FFFFFF">grayscale</TD></TR><TR> <TD BGCOLOR="#e0e0e0"><TT>/c2</TT></TD><TD BGCOLOR="#FFFFFF">RGB</TD></TR><TR> <TD BGCOLOR="#e0e0e0"><TT>/c3</TT></TD><TD BGCOLOR="#FFFFFF">palette</TD></TR><TR> <TD BGCOLOR="#e0e0e0"><TT>/c4</TT></TD><TD BGCOLOR="#FFFFFF">grayscale + alpha</TD></TR><TR> <TD BGCOLOR="#e0e0e0"><TT>/c6</TT></TD><TD BGCOLOR="#FFFFFF">RGB + alpha</TD></TR><TR> <TD BGCOLOR="#e0e0e0" COLSPAN=2><TT>/c1 & /c5</TT> are not valid</TD> </TR></TABLE> </TD></TR></TABLE> <p>The number codes are from the official PNG specification.</p> <p>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.</p> </TD> <TD VALIGN=top WIDTH="50%"> <H2>Input file types:</H2> <TABLE CELLSPACING=0 CELLPADDING=0><TR><TD BGCOLOR=gray> <TABLE CELLSPACING=1 CELLPADDING=6 WIDTH="100%"> <TR><TD BGCOLOR="#e0e0e0" VALIGN=top>PNG</TD><TD BGCOLOR="#FFFFFF">All types supported except the rarely used 16-bit color depths.</TD></TR> <TR><TD BGCOLOR="#e0e0e0" VALIGN=top>GIF</TD><TD BGCOLOR="#FFFFFF">Full support. (Extracts first frame of animations)</TD></TR> <TR><TD BGCOLOR="#e0e0e0" VALIGN=top>BMP</TD><TD BGCOLOR="#FFFFFF">All uncompressed BMP formats are supported.</TD></TR> <TR><TD BGCOLOR="#e0e0e0" VALIGN=top>JPG</TD><TD BGCOLOR="#FFFFFF">Full support.</TD></TR> <TR><TD BGCOLOR="#e0e0e0" VALIGN=top>TGA</TD><TD BGCOLOR="#FFFFFF">Full support.</TD> <TR><TD BGCOLOR="#e0e0e0" VALIGN=top>PCX</TD><TD BGCOLOR="#FFFFFF">Supports 8 and 24 bit PCX</TD> </TR> </TABLE> </TD></TR></TABLE> <P>Input file names are not case sensitive. The .png extension can be omitted from PNG filenames both for input and output.</P> <H2>Windows clipboard option: /i</H2> <P>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.</P> </TD> </TR><TR><TD VALIGN=top WIDTH="50%"> <H2>Filter options: /f#</H2> <TABLE CELLSPACING=0 CELLPADDING=0><TR><TD BGCOLOR=gray> <TABLE CELLSPACING=1 CELLPADDING=6 WIDTH="100%"> <TR><TD BGCOLOR="#e0e0e0"><TT>/f0</TT></TD><TD BGCOLOR="#FFFFFF">None</TD></TR> <TR><TD BGCOLOR="#e0e0e0"><TT>/f1</TT></TD><TD BGCOLOR="#FFFFFF">Sub (delta x)</TD></TR> <TR><TD BGCOLOR="#e0e0e0"><TT>/f2</TT></TD><TD BGCOLOR="#FFFFFF">Up (delta y)</TD></TR> <TR><TD BGCOLOR="#e0e0e0"><TT>/f3</TT></TD><TD BGCOLOR="#FFFFFF" NOWRAP>Average (delta x&y)</TD></TR> <TR><TD BGCOLOR="#e0e0e0"><TT>/f4</TT></TD><TD BGCOLOR="#FFFFFF">Paeth</TD></TR> <TR><TD BGCOLOR="#e0e0e0"><TT>/f5</TT></TD><TD BGCOLOR="#FFFFFF">Adaptive (mixed)</TD></TR> <TR><TD BGCOLOR="#e0e0e0"><TT>/f6</TT></TD><TD BGCOLOR="#FFFFFF">Reuse (copy line by line from source PNG)</TD></TR> </TABLE> </TD></TR></TABLE> <p>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.</p> <H2>Strategy options: /s#</H2> <TABLE CELLSPACING=0 CELLPADDING=0><TR><TD BGCOLOR=gray> <TABLE CELLSPACING=1 CELLPADDING=6 WIDTH="100%"> <TR><TD BGCOLOR="#e0e0e0"><TT>/s0</TT></TD><TD BGCOLOR="#FFFFFF">Xtreme! (Slowest)</TD></TR> <TR><TD BGCOLOR="#e0e0e0"><TT>/s1</TT></TD><TD BGCOLOR="#FFFFFF">Intense (Slow)</TD></TR> <TR><TD BGCOLOR="#e0e0e0"><TT>/s2</TT></TD><TD BGCOLOR="#FFFFFF">Longest Match (Fast)</TD></TR> <TR><TD BGCOLOR="#e0e0e0"><TT>/s3</TT></TD><TD BGCOLOR="#FFFFFF">Huffman Only (Faster)</TD></TR> <TR><TD BGCOLOR="#e0e0e0"><TT>/s4</TT></TD><TD BGCOLOR="#FFFFFF" NOWRAP>Uncompressed (Fastest)</TD></TR> </TABLE> </TD></TR></TABLE> <p>The default method is Xtreme (/s0). It takes the most time to finish, but in most cases it achieves the best results.</p> <H2>PNGOUT.EXE exit codes:<font size=2> (for advanced users - i.e. batch files)</font></H2> <TABLE CELLSPACING=0 CELLPADDING=0><TR><TD BGCOLOR=gray> <TABLE CELLSPACING=1 CELLPADDING=6 WIDTH="100%"> <TR><TD BGCOLOR="#e0e0e0"><TT>0</TT></TD><TD BGCOLOR="#FFFFFF">Wrote file</TD></TR> <TR><TD BGCOLOR="#e0e0e0"><TT>1</TT></TD><TD BGCOLOR="#FFFFFF">File error</TD></TR> <TR><TD BGCOLOR="#e0e0e0"><TT>2</TT></TD><TD BGCOLOR="#FFFFFF">Unable to compress further</TD></TR> <TR><TD BGCOLOR="#e0e0e0"><TT>3</TT></TD><TD BGCOLOR="#FFFFFF">Bad options</TD></TR> </TABLE> </TD></TR></TABLE> <TD BGCOLOR="#F0F0F0" VALIGN=top WIDTH="50%"> <H2>Other options:</H2> <TABLE CELLSPACING=0 CELLPADDING=0> <TR><TD BGCOLOR=gray> <TABLE CELLSPACING=1 CELLPADDING=6 WIDTH="100%"> <TR><TD BGCOLOR="#e0e0e0" VALIGN=top><TT>/k0</TT></TD><TD BGCOLOR="#FFFFFF">Remove all unnecessary chunks. (default)</TD></TR> <TR><TD BGCOLOR="#e0e0e0" VALIGN=top><TT>/k1</TT></TD><TD BGCOLOR="#FFFFFF">Keep all chunks.</TD></TR> <TR><TD BGCOLOR="#e0e0e0" VALIGN=top><TT>/kCHUNK</TT></TD><TD BGCOLOR="#FFFFFF">Keep 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: <TT>/kbKGD,tEXt,gAMA,pHYs</TT></TD></TR> <TR><TD BGCOLOR="#e0e0e0" VALIGN=top><TT>/kp</TT></TD><TD BGCOLOR="#FFFFFF">Keep 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.</TD></TR> <TR><TD BGCOLOR="#e0e0e0" VALIGN=top><TT>/ks</TT></TD><TD BGCOLOR="#FFFFFF">Keep 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.</TD></TR> <TR><TD BGCOLOR="#e0e0e0" VALIGN=top><TT>/kt</TT></TD><TD BGCOLOR="#FFFFFF">Keep the file's original date and time. By default, the file's date and time will be replaced with the current time.</TD></TR> <TR><TD BGCOLOR="#e0e0e0" VALIGN=top><TT>/v</TT></TD><TD BGCOLOR="#FFFFFF">Verbose 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.</TD></TR> <TR><TD BGCOLOR="#e0e0e0" VALIGN=top><TT>/q</TT></TD><TD BGCOLOR="#FFFFFF">Quiet mode. Don't display any output.</TD></TR> <TR><TD BGCOLOR="#e0e0e0" VALIGN=top><TT>/l (/L)</TT></TD><TD BGCOLOR="#FFFFFF">List mode. Displays autodetected options from input file then quits before doing compression. May be helpful for batch optimizers.</TD></TR> <TR><TD BGCOLOR="#e0e0e0" VALIGN=top><TT>/y</TT></TD><TD BGCOLOR="#FFFFFF">Assume Yes at the 'overwrite file?' prompt. This is useful if you intend to run PNGOUT from a script.</TD></TR> <TR><TD BGCOLOR="#e0e0e0" VALIGN=top><TT>/force</TT></TD><TD BGCOLOR="#FFFFFF">Write file even if bigger. By default, PNGOUT will not overwrite a PNG file if it was not able to compress it further.</TD></TR> </TABLE></TR> </TABLE> </TABLE> <font size=1> <p>This PNGOUT tutorial was originally written by <a href=http://www.mywebsite.force9.co.uk/png>Kerry Watson</a>, with updates by <a href=http://advsys.net/ken>Ken Silverman</a> and Matthew Fearnley</p> <p>Last updated: 06/21/2009</p> </font> </BODY></HTML>