Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
pngcrush(1)
Edit
PageHistory
Diff
Info
LikePages
!! pngcrush(1) !!NAME pngcrush -- optimizes (or modifies) PNG (Portable Network Graphics) files. !!SYNOPSIS __pngcrush__ [[__''options]''__ __''[[file1.png]''__ __''[[file2.png]'' ...__ __pngcrush -d ''dir [[options]''__ __''[[file1.png]''__ __''[[file2.png]'' ...__ __pngcrush -e ''ext [[options]''__ __''[[file1.png]''__ __''[[file2.png]'' ...__ !!DESCRIPTION __pngcrush__ is an optimizer for PNG (Portable Network Graphics) files. Its main purpose is to reduce the size of the file's IDAT chunk (or stream). __pngcrush__ can also be used to modify a PNG's ancillary chunks (example: transparency information or textual comments). Some familiarity with the PNG (pronounced 'ping') format may be helpful to users of __pngcrush__. __pngcrush__ has reasonable defaults so running with no options may produce smaller files. This document briefly describes the PNG format where necessary to understand __pngcrush__. For complete documentation, see : ftp://ftp.freesoftware.com/pub/png/. The actual pixel data of a PNG is contained in one or many IDAT chunks. To make an IDAT chunk PNG encoders take the raw pixel data, filter it with one of 5 different filters (See Section __''"Filter Types"''__ ) then compress it. __pngcrush__ reduces the size of PNG files by choosing a different filter or compression methods from those used in the input file. __pngcrush__ tries multiple filter/compression methods and compares the size of the resulting IDAT chunk. The filter/compression method with the smallest IDAT chunk is chosen for the output file. The filter and compression levels __pngcrush__ tries are controlled by command line options. All of the filter methods and compression levels are lossless; they will not reduce image quality. In addition to reducing the size of a PNG file, __pngcrush__ can modify ancillary chunks. Ancillary chunks are optional information including transparency (tRNS), gamma (gAMMA), standard RGB color space conformance (sRGB) or textual information (iTXt, tEXt or zTXt). See the associated command line options for details on manipulating these chunks. !!OPTIONS ;__-already ''size''__: If file has an IDAT chunk greater than the integer __''size''__, it will be considered to be already crushed and will not be processed further. ;__-bit_depth ''n''__: Force output bit depth to __''n''__. See Section __''"Color''__ __''Types"''__ for bit depth restrictions. ;__-bkgd ''r g b''__: Specify the default background color for the image. Some PNG viewers will use this background when displaying the image. Background is specified by __''r''__, __''g''__ and __''b''__ integers between 0 and (2 bitdepth)-1. For output color type 0 and 4 (gray, see section __''"Color''__ __''Types"''__ ) the green index is used as the grey level of the background. ;__-brute__: Use brute force, try 114 different filter/compression methods [[11-124]. This option is very time-consuming and generally not worthwhile. You can restrict this option to certain filter types, compression levels, or strategies by following it with __-f__ __''filter,''__ __-l__ __''level,''__ __''or''__ __-z__ __''strategy. For example:''__ __pngcrush__ -brute -f 0 infile.png Will try only methods that use filter type 0. ;__-c type__: Set the output image color type to __''type''__, one of [[0, 2, 4, or 6] (see section __''"Color''__ __''Types"''__ ). Future versions of __pngcrush__ will also allow color type 3, if there are 256 or fewer colors present in the input file. Color types 4 and 6 are padded with an opaque alpha channel if the input file does not have alpha information. You can use 0 or 4 to convert color to grayscale. Use 0 or 2 to delete an unwanted alpha channel. Default is to use same color type as the input file. ;__-cc__: Color counting. This option allows __pngcrush__ to perform further optimizations on the image based on the number of colors and the format of the imput image. With this option __pngcrush__ will remove an alpha channel from an opaque image and/or will reduce a true color image that is completely grey to greyscale representation. ;__-d ''dir''__: Specify a directory for all output files. All output files will have the same name as their respective input files. ;__-dou__: Double the images gamma. This is used for fixing gamma in !PhotoShop 5.0c5.02 files. It has been claimed that the PS5 bug is actually more complex than that, in some unspecified way. ;__-e ''ext''__: Specify a new extention __''ext''__ for all output files. ;__-exit__: Forces __pngcrush__ to call exit() rather than return() when it is finished. It is unclear to this writer why this option exists. ;__-f: ''filter''__ Specify __''filter''__ (see section __''"Filter Types"''__ ) to use with the method specified in the preceding __-m__ or __-brute__ option. Valid filter types are [[0-4] : use specified filter, [[5]: use adaptive filtering. ;__-fix__: Fix otherwise fatal conditions such as bad CRCs. The CRC (Cyclic Redundancy Check) is present in every chunk and can alert the decoder of corrupt data. ;__-force__: Write a new output file even if larger than input. Otherwise the input file will be copied to output if it is smaller than any generated file and no chunk additions, removals, or changes were requested. ;__-g: ''gamma''__ Value to insert in gAMA chunk, only if the input file has no gAMA chunk. To replace an existing gAMA chunk, use the __-replace_gamma__ option. Some decoders will use the gAMA chunk to more accurately display the image. __''gamma''__ relates the output intensity to the input samples (input_sample = light_out GAMMA). __''gamma''__ can be any integer between 0 and 2 32 and is interpreted as GAMMA*100000. For example, if you wanted a GAMMA of 1/2.2, you would enter 45455 for __''gamma''__. __-h__ Display help and legal notices. ;__-itxt [[b|a] ''keyword text''__: Insert an (uncompressed) iTXt chunk. __[[b|a]__ indicates whether chunk should be inserted __''b''__efore or __''a''__fter the IDAT chunk, (see Section __''"Text Chunks"''__ ). ;__-l: ''level''__ zlib compression __''level''__ to use on the filtered IDAT chunk with the method specified by the preceding __-m__ or __-brute__ option. zlib compression levels are integers between 0 and 9. 0 = no compression, 1 = fastest compression, and 9 = best compression. ;__-m: ''method'' pngcrush__ __''method''__ [[0-200] to try (0 means try all of 1-10). Can be repeated as in __-m 1 -m 4 -m__ __7__. This can be useful if you run out of memory when __pngcrush__ tries methods 2, 3, 5, 6, 8, 9, or 10 which use filtering and are memory intensive. Method 1, 4, and 7 use no filtering; methods 11 and up use specified filter, compression level, and strategy. ;__-max ''maximum''_''IDAT''_''size''__: Set the maximum idat size to be used when creating the compression buffer.[[1 through 524288] ;__-n__: Do not do compression or write output file. This is useful in conjunction with the __-v__ option to get info, or to test decode speed. __-no_cc__ No color counting, see the __-cc__ option. ;__-p__: This option tells __pngcrush__ to pause and wait for [[enter] key whenever the screen fills. ;__-plte_len ''n''__: Truncates the PLTE. The PLTE chunk contains from 1 to 256 palette entries. Be sure not to truncate it to less than the greatest index present in IDAT. __-q__ quiet, the opposite of verbose. ;__-rem ''chunkname''__: Name of an ancillary chunk or optional PLTE to be removed. Be careful with this. Please don't use this feature to remove transparency, gamma, copyright, or other valuable information. To remove several different chunks, repeat: __-rem__ __tEXt -rem pHYs__. Known chunks (those in the PNG spec or extensions document) can be named with all lower-case letters, so __-rem bkgd__ is equivalent to __-rem bKGD__. But note: __-rem text__ removes all forms of text chunks; Exact case is required to remove unknown chunks. To do surgery with a chain-saw, __-rem alla__ removes all known ancillary chunks except for tRNS, and __-rem allb__ removes all but tRNS and gAMA. ;__-replace_gamma ''gamma''__: Force a specified __''gamma''__ in the output file even if gAMA is present in the input. See the __-g__ for more information. ;__-res: ''dpi''__ Write a pHYs chunk with a resolution of __''dpi''__. The pHYs chunk indicates the desired pixel size. ;__-save__: Force writing of unknown chunks. If the input image has chunks that are not part of the PNG specification, they should not be discarded. ;__-srgb ''n''__: Set value of rendering intent for sRGB chunk to __''n''__ where __''n''__ is between 0 and 3. The appropriate rendering intent depends on how the image will be used: * 0 - Perceptual: when good adaptation: to the output device gamut at the expense of colorimetric accuracy is desired, example: photographs. * 1 - Relative colorimetric: images: requiring color appearance matching (relative to the output device white point), example: logos. * 2: Saturation: preservation of saturation at the expense of hue and lightness is preferred, example: charts and graphs. * 3: Absolute colorimetric: images: requiring preservation of absolute colorimetry, example: proofs (previews of images destined for a different output device). ;__-text [[b|a] ''keyword text''__: Insert a tEXt chunk. __[[b|a]__ indicates whether chunk should be inserted __''b''__efore or __''a''__fter the IDAT chunk, (see Section __''"Text Chunks"''__ ). ;__-trns ''index red green blue gray''__: Insert a tRNS (transparency) chunk, if no tRNS chunk found in file. You must give all five parameters regardless of the color type, scaled to the output bit depth. See the PNG documentation for details. ;__-v__: Display more detailed information. Repeat the option (use "-v -v") for even more. ;__-w ''size''__: Specify __''size''__ in kbytes (or bytes in the case of 512) of the sliding compression window where size is one of [[32, 16, 8, 4, 2, 1, or 512]. It's best to use the default (32) unless you run out of memory. The program will use a smaller window anyway when the uncompressed file is smaller than 16k. ;__-z ''strategy''__: Specify the zlib compression __''strategy''__ [[0, 1, or 2] to be used on the filtered IDAT chunk for the method of the preceeding __-m__. The zlib strategy parameter tunes the compression algorithm and is one of: * 0 : default, most compression is aimed towards string matching * 1 : some string matching, some huffman coding * 2 : use only huffman coding ;__-zitxt [[b|a] ''keyword text''__: Insert a zTXt chunk. __[[b|a]__ indicates whether chunk should be inserted __''b''__efore or __''a''__fter the IDAT chunk, (see Section __''"Text Chunks"''__ ). ;__-ztxt [[b|a] ''keyword text''__: zTXt chunk to insert (see -text). !!Color Types The PNG specification provides for five color types. The color type determines how the IDAT chunk will be interpreted by the decoder. Choosing a color type appropriate for the color information in an image can reduce the size (See the __-cc__ option). Following are the PNG color types followed by their supported bit depths (Note __pngcrush__ does not support changing a file to color type 3 from another color type.): * 0 : greyscale without alpha channel (1,2,4,8,16) * 2 : true color without alpha channel (8,16) * 3 : indexed color (1,2,4,8) * 4 : greyscale with alpha channel (8,16) * 6 : true color with alpha channel (8,16) An alpha channel represents transparency on a per pixel basis. An alpha value of zero is completely transparent. An alpha channel of 2 bitdepth-1 is completely opaque. !!Filter Types The IDAT chunk can optionally be filtered before compression. These filters can make the IDAT chunk more compressible without losing any data and result in a smaller PNG file. These filters are applied to the bytes of the IDAT chunk, not the pixels. Following is a brief description of the filters, see the PNG specification for details: * 0 : no filter * 1 : 'sub' transmits the difference between each byte and the value of the corresponding byte of the prior pixel. * 2 : 'up' transmits the difference between each byte and the value of the corresponding byte of the pixel above this pixel * 3 : 'average' transmits the difference between each byte and the average of the btyes described in filters 1 and 2 * 4 : 'paeth' computes a simple linear function of the corresponding byte in three neighboring pixels (paeth_predictor = left + above - upper left), then transmits the difference between the byte in question and the neighboring byte closest to the value of paeth_predictor. !!Text Chunks Textual information pertaining to an image can be conveyed with the tEXt, iTXt and zTXt chunks. All text chunks consist of a keyword followed by a string. The following keywords are defined in the PNG specification: (you may invent keywords for other purposes): __''Title''__: Short title or caption for image __''Author''__: Name of image's creator __''Description''__: Longer description of image __''Copyright''__: Copyright notice __''Creation Time''__: Time of original image creation __''Software''__: Software used to create the image __''Disclaimer''__: Legal disclaimer __''Warning''__: Warning of nature of content __''Source''__: Device used to create the image __''Comment''__: Miscellaneous comment. An iTXt chunk stores text in the ISO/IEC 8859-1 (Latin-1) character set. zTXt chunks also use the Latin-1 character set, but the text is compressed. This can be useful for large text chunks. iTXt chunks consist of text in the UTF-8 of the Unicode character set. __''keyword''__ must be at least 1 character and less than 80 characters. __''text''__ must be less than 2048 characters when using __pngcrush__ For now, you can only add ten tEXt, iTXt, or zTXt chunks per __pngcrush__ run. !!SEE ALSO png(5), libpng(3), zlib(3). !!AUTHOR This manual page was written by David Whedon dwhedon@gordian.com for the __Debian GNU/Linux__ system (but may be used by others). Much of the information was gleaned from "PNG (Portable Network Graphics) Specification, Version 1.2"
2 pages link to
pngcrush(1)
:
Man1p
PNG
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.