1PNGCRUSH(1) PNGCRUSH(1)
2
3
4
6 pngcrush - optimizes (or modifies) PNG (Portable Network Graphics)
7 files.
8
10 pngcrush [ options ] [ infile.png ] [ outfile.png ]
11
12 pngcrush -e ext [ options ] [ file1.png ] [ file2.png ] ...
13
14 pngcrush -d dir [ options ] [ file1.png ] [ file2.png ] ...
15
17 pngcrush is an optimizer for PNG (Portable Network Graphics) files. Its
18 main purpose is to reduce the size of the file's IDAT chunk (or
19 stream). pngcrush can also be used to modify a PNG's ancillary chunks
20 (example: transparency information or textual comments). Some familiar‐
21 ity with the PNG (pronounced 'ping') format may be helpful to users of
22 pngcrush. pngcrush has reasonable defaults so running with no options
23 may produce smaller files. This document briefly describes the PNG for‐
24 mat where necessary to understand pngcrush. For complete documentation,
25 see :
26
27 http://www.libpng.org/pub/png/.
28
29 The actual pixel data of a PNG is contained in one or many IDAT chunks.
30 To make an IDAT chunk PNG encoders take the raw pixel data, filter it
31 with one of 5 different filters (See Section pngcrush(1)) then compress
32 it. pngcrush reduces the size of PNG files by choosing a different fil‐
33 ter or compression methods from those used in the input file. pngcrush
34 tries multiple filter/compression methods and compares the size of the
35 resulting IDAT chunk. The filter/compression method with the smallest
36 IDAT chunk is chosen for the output file. The filter and compression
37 levels pngcrush tries are controlled by command line options. All of
38 the filter methods and compression levels are lossless; they will not
39 reduce image quality.
40
41 In addition to reducing the size of a PNG file, pngcrush can modify
42 ancillary chunks. Ancillary chunks are optional information including
43 transparency (tRNS), gamma (gAMMA), standard RGB color space confor‐
44 mance (sRGB) or textual information (iTXt, tEXt or zTXt). See the asso‐
45 ciated command line options for details on manipulating these chunks.
46
48 -already size
49 If file has an IDAT chunk greater than the integer size, it will
50 be considered to be already crushed and will not be processed
51 further.
52
53 -bit_depth n
54 Force output bit depth to n. See Section pngcrush(1)for bit
55 depth restrictions.
56
57 -bkgd r g b
58 Specify the default background color for the image. Some PNG
59 viewers will use this background when displaying the image.
60 Background is specified by r, g and b integers between 0 and
61 (2bitdepth)-1. For output color type 0 and 4 (gray, see section
62 pngcrush(1)) the green index is used as the gray level of the
63 background.
64
65 -brute Use brute force, try 114 different filter/compression methods
66 [11-124]. This option is very time-consuming and generally not
67 worthwhile. You can restrict this option to certain filter
68 types, compression levels, or strategies by following it with -f
69 filter, -l level, or -z strategy. For example:
70
71 pngcrush -brute -f 0 infile.png
72
73 Will try only methods that use filter type 0.
74
75 -c type
76 Set the output image color type to type, one of [0, 2, 4, or 6]
77 (see section pngcrush(1)). Future versions of pngcrush will also
78 allow color type 3, if there are 256 or fewer colors present in
79 the input file. Color types 4 and 6 are padded with an opaque
80 alpha channel if the input file does not have alpha information.
81 You can use 0 or 4 to convert color to grayscale. Use 0 or 2 to
82 delete an unwanted alpha channel. Default is to use same color
83 type as the input file.
84
85 -d dir Specify a directory for all output files. All output files will
86 have the same name as their respective input files.
87
88 -dou Double the images gamma. This is used for fixing gamma in Photo‐
89 Shop 5.0c5.02 files. It has been claimed that the PS5 bug is
90 actually more complex than that, in some unspecified way.
91
92 -e ext Specify a new extension ext for all output files.
93
94 -exit Forces pngcrush to call exit() rather than return() when it is
95 finished. It is unclear to this writer why this option exists.
96
97 -f filter
98 Specify filter (see section pngcrush(1)) to use with the method
99 specified in the preceding -m or -brute option. Valid filter
100 types are [0-4] : use specified filter, [5]: use adaptive fil‐
101 tering.
102
103 -fix Fix otherwise fatal conditions such as bad CRCs. The CRC (Cyclic
104 Redundancy Check) is present in every chunk and can alert the
105 decoder of corrupt data.
106
107 -force Write a new output file even if larger than input. Otherwise the
108 input file will be copied to output if it is smaller than any
109 generated file and no chunk additions, removals, or changes were
110 requested.
111
112 -g gamma
113 Value to insert in gAMA chunk, only if the input file has no
114 gAMA chunk. To replace an existing gAMA chunk, use the
115 -replace_gamma option. Some decoders will use the gAMA chunk to
116 more accurately display the image. gamma relates the output
117 intensity to the input samples (input_sample = light_out^GAMMA).
118 gamma can be any integer between 0 and 2^32 and is interpreted
119 as GAMMA*100000. For example, if you wanted a GAMMA of 1/2.2,
120 you would enter 45455 for gamma.
121
122 -h Display help and legal notices.
123
124 -itxt b|a keyword text
125 Insert an (uncompressed) iTXt chunk. b|a indicates whether chunk
126 should be inserted before or after the IDAT chunk, (see Section
127 pngcrush(1)).
128
129 -keep chunk_name
130 keep named chunk chunk_name even if the PNG datastream becomes
131 invalid. Currently only dSIG is recognized as an acceptable
132 value.
133
134 -l level
135 zlib compression level to use on the filtered IDAT chunk with
136 the method specified by the preceding -m or -brute option. zlib
137 compression levels are integers between 0 and 9. 0 = no compres‐
138 sion, 1 = fastest compression, and 9 = best compression.
139
140 -loco Make the file more compressible by performing a lossless,
141 reversible, color transformation. The resulting file is a MNG
142 format file, not a PNG, and should be given the .mng file exten‐
143 sion. The loco option has no effect on grayscale or indexed-
144 color PNG files.
145
146 -m method
147 pngcrush method [0-200] to try (0 means try all of 1-10). Can be
148 repeated as in -m 1 -m 4 -m 7. This can be useful if you run out
149 of memory when pngcrush tries methods 2, 3, 5, 6, 8, 9, or 10
150 which use filtering and are memory intensive. Method 1, 4, and 7
151 use no filtering; methods 11 and up use specified filter, com‐
152 pression level, and strategy.
153
154 -max maximum_IDAT_size
155 Set the maximum idat size to be used when creating the compres‐
156 sion buffer.[1 through 524288]
157
158 -mng write a new MNG, do not crush embedded PNGs.
159
160 -n Do not do compression or write output file. This is useful in
161 conjunction with the -v option to get info, or to test decode
162 speed.
163
164 -p This option tells pngcrush to pause and wait for [enter] key
165 whenever the screen fills.
166
167 -plte_len n
168 Truncates the PLTE. The PLTE chunk contains from 1 to 256 pal‐
169 ette entries. Be sure not to truncate it to less than the great‐
170 est index present in IDAT.
171
172 -q quiet, the opposite of verbose.
173
174 -rem chunkname
175 Name of an ancillary chunk or optional PLTE to be removed. Be
176 careful with this. Please don't use this feature to remove
177 transparency, gamma, copyright, or other valuable information.
178 To remove several different chunks, repeat: -rem tEXt -rem pHYs.
179 Known chunks (those in the PNG spec or extensions document) can
180 be named with all lower-case letters, so -rem bkgd is equivalent
181 to -rem bKGD. But note: -rem text removes all forms of text
182 chunks; Exact case is required to remove unknown chunks. To do
183 surgery with a chain-saw, -rem alla removes all known ancillary
184 chunks except for tRNS, and -rem allb removes all but tRNS and
185 gAMA.
186
187 -replace_gamma gamma
188 Force a specified gamma in the output file even if gAMA is
189 present in the input. See the -g for more information.
190
191 -res dpi
192 Write a pHYs chunk with a resolution of dpi. The pHYs chunk
193 indicates the desired pixel size.
194
195 -save Force writing of unknown chunks. If the input image has chunks
196 that are not part of the PNG specification, they should not be
197 discarded.
198
199 -srgb n
200 Set value of rendering intent for sRGB chunk to n where n is
201 between 0 and 3. The appropriate rendering intent depends on how
202 the image will be used:
203
204 0 - Perceptual: when good adaptation to the output device gamut
205 at the expense of colorimetric accuracy is desired, example:
206 photographs.
207
208 1 - Relative colorimetric: images requiring color appearance
209 matching (relative to the output device white point), example:
210 logos.
211
212 2: Saturation: preservation of saturation at the expense of hue
213 and lightness is preferred, example: charts and graphs.
214
215 3: Absolute colorimetric: images requiring preservation of abso‐
216 lute colorimetry, example: proofs (previews of images destined
217 for a different output device).
218
219 -text [b|a] keyword text
220 Insert a tEXt chunk. [b|a] indicates whether chunk should be
221 inserted before or after the IDAT chunk, (see Section
222 pngcrush(1)).
223
224 -newtimestamp
225 Reset file modification time to newer time stamp. This is the
226 default.
227
228 -oldtimestamp
229 Retain input file modification time stamp. The default is -new‐
230 timestamp which is the opposite of this option.
231
232 -trns index red green blue gray
233 Insert a tRNS (transparency) chunk, if no tRNS chunk found in
234 file. You must give all five parameters regardless of the color
235 type, scaled to the output bit depth. See the PNG documentation
236 for details.
237
238 -trns_array n trns[0] trns[1] ... trns[n-1]
239 Insert a tRNS (transparency) chunk, if no tRNS chunk found in
240 file. See the PNG documentation for details.
241
242 -v Display more detailed information. Repeat the option (use "-v
243 -v") for even more.
244
245 -w size
246 Specify size in kbytes (or bytes in the case of 512) of the
247 sliding compression window where size is one of [32, 16, 8, 4,
248 2, 1, or 512]. It's best to use the default (32) unless you run
249 out of memory. The program will use a smaller window anyway when
250 the uncompressed file is smaller than 16k.
251
252 -z strategy
253 Specify the zlib compression strategy [0, 1, or 2] to be used on
254 the filtered IDAT chunk for the method of the preceding -m. The
255 zlib strategy parameter tunes the compression algorithm and is
256 one of:
257
258 · 0 : default, most compression is aimed towards string matching
259
260 · 1 : some string matching, some Huffman coding
261
262 · 2 : use only Huffman coding
263
264 -zitxt [b|a] keyword text
265 Insert a zTXt chunk. [b|a] indicates whether chunk should be
266 inserted before or after the IDAT chunk, (see Section
267 pngcrush(1)).
268
269 -ztxt [b|a] keyword text
270 zTXt chunk to insert (see -text).
271
273 The PNG specification provides for five color types. The color type
274 determines how the IDAT chunk will be interpreted by the decoder.
275 Choosing a color type appropriate for the color information in an image
276 can in principle reduce the size. However, certain combinations of -c
277 and -bit_depth require color counting which is currently disabled. In
278 such cases no reduction will take place. Following are the PNG color
279 types followed by their supported bit depths (Note pngcrush does not
280 support changing a file to color type 3 from another color type.):
281
282 · 0 : grayscale without alpha channel (1,2,4,8,16)
283
284 · 2 : true color without alpha channel (8,16)
285
286 · 3 : indexed color (1,2,4,8)
287
288 · 4 : grayscale with alpha channel (8,16)
289
290 · 6 : true color with alpha channel (8,16)
291
292 An alpha channel represents transparency on a per pixel basis. An alpha
293 value of zero is completely transparent. An alpha channel of 2^bit‐
294 depth-1 is completely opaque.
295
297 The IDAT chunk can optionally be filtered before compression. These
298 filters can make the IDAT chunk more compressible without losing any
299 data and result in a smaller PNG file. These filters are applied to the
300 bytes of the IDAT chunk, not the pixels. Following is a brief descrip‐
301 tion of the filters, see the PNG specification for details:
302
303 · 0 : no filter
304
305 · 1 : 'sub' transmits the difference between each byte and the value of
306 the corresponding byte of the prior pixel.
307
308 · 2 : 'up' transmits the difference between each byte and the value of
309 the corresponding byte of the pixel above this pixel
310
311 · 3 : 'average' transmits the difference between each byte and the
312 average of the bytes described in filters 1 and 2
313
314 · 4 : 'paeth' computes a simple linear function of the corresponding
315 byte in three neighboring pixels (paeth_predictor = left + above -
316 upper left), then transmits the difference between the byte in ques‐
317 tion and the neighboring byte closest to the value of paeth_predic‐
318 tor.
319
321 Textual information pertaining to an image can be conveyed with the
322 tEXt, iTXt and zTXt chunks. All text chunks consist of a keyword fol‐
323 lowed by a string. The following keywords are defined in the PNG speci‐
324 fication: (you may invent keywords for other purposes):
325
326 Title: Short title or caption for image
327
328 Author: Name of image's creator
329
330 Description: Longer description of image
331
332 Copyright: Copyright notice
333
334 Creation Time: Time of original image creation
335
336 Software: Software used to create the image
337
338 Disclaimer: Legal disclaimer
339
340 Warning: Warning of nature of content
341
342 Source: Device used to create the image
343
344 Comment: Miscellaneous comment.
345
346 A tEXt chunk stores text in the ISO/IEC 8859-1 (Latin-1) character set.
347 zTXt chunks also use the Latin-1 character set, but the text is com‐
348 pressed. This can be useful for large text chunks. iTXt chunks consist
349 of text in the UTF-8 of the Unicode character set.
350
351 keyword must be at least 1 character and less than 80 characters. text
352 must be less than 2048 characters when using pngcrush For now, you can
353 only add ten tEXt, iTXt, or zTXt chunks per pngcrush run.
354
356 png(5), libpng(3), zlib(3).
357
359 This manual page was written by David Whedon <dwhedon@gordian.com> for
360 the Debian GNU/Linux system (but may be used by others). Much of the
361 information was gleaned from "PNG (Portable Network Graphics) Specifi‐
362 cation, Version 1.2"
363
364
365
366 Mon Apr 30, 2001 PNGCRUSH(1)