1OPTIPNG(1)                  General Commands Manual                 OPTIPNG(1)
2
3
4

NAME

6       OptiPNG - Optimize Portable Network Graphics files
7
8

SYNOPSIS

10       optipng [-? | -h | -help]
11       optipng [options...] files...
12
13

DESCRIPTION

15       The  OptiPNG  program  shall attempt to optimize PNG files, i.e. reduce
16       their size to a minimum, without losing semantic information. In  addi‐
17       tion,  this  program  shall perform a suite of auxiliary functions like
18       integrity checks, metadata recovery and pixmap-to-PNG conversion.
19
20       The optimization attempts are not  guaranteed  to  succeed.  Valid  PNG
21       files  that  cannot  be optimized by this program are normally left in‐
22       tact; their size will not grow. The user may request to  override  this
23       default behavior.
24
25

FILES

27       The  input  files  are  raster image files encoded either in PNG format
28       (the native format), or in an external format. The currently  supported
29       external formats are GIF, BMP, PNM and TIFF.
30
31       OptiPNG processes each image file given in the command line as follows:
32
33       - If the image is in PNG format:
34
35              Attempts to optimize the given file in-place. If optimization is
36              successful, or if the option -force  is  enabled,  replaces  the
37              original  file  with its optimized version. The original file is
38              backed up if the option -keep is enabled.
39
40       - If the image is in an external format:
41
42              Creates an optimized PNG version of the given file.  The  output
43              file  name  is composed from the original file name and the .png
44              extension.
45
46       Existing files are not overwritten, unless the option -clobber  is  en‐
47       abled.
48
49

OPTIONS

51   General options
52       -?, -h, -help
53              Show a complete summary of options.
54
55       -backup, -keep
56              Keep a backup of the modified files.
57
58       -clobber
59              Overwrite the existing output and backup files.
60              Under this option, if the option -backup is not enabled, the old
61              backups of the overwritten files are deleted.
62
63       -dir directory
64              Write the output files to directory.
65
66       -fix   Enable error recovery. This option has no effect on valid  input
67              files.
68              The  program will spend a reasonable amount of effort to recover
69              as much data as possible, without  increasing  the  output  file
70              size,  but  the success cannot be generally guaranteed. The pro‐
71              gram may even increase the file size,  e.g.,  by  reconstructing
72              missing  critical  data. Under this option, integrity shall take
73              precedence over file size.
74              When this option is not used, the invalid input files  are  left
75              unprocessed.
76
77       -force Enforce writing of a new output file.
78              This  option  overrides the program's decision not to write such
79              file, e.g. when the PNG input is digitally signed (using  dSIG),
80              or when the PNG output becomes larger than the PNG input.
81
82       -log file
83              Log  messages  to  file.  For safety reasons, file must have the
84              extension .log.
85              This option is deprecated and will be  removed  eventually.  Use
86              shell redirection.
87
88       -out file
89              Write  output  file  to file.  The command line must contain ex‐
90              actly one input file.
91
92       -preserve
93              Preserve file attributes (time stamps, file access rights, etc.)
94              where applicable.
95
96       -quiet, -silent
97              Run in quiet mode.
98              The  messages  are  still  written to the log file if the option
99              -log is enabled.
100
101       -simulate
102              Run in simulation mode: perform the trials, but  do  not  create
103              output files.
104
105       -v     Enable the options -verbose and -version.
106
107       -verbose
108              Run in verbose mode.
109
110       -version
111              Show copyright, version and build info.
112
113       --     Stop option switch parsing.
114
115   PNG encoding and optimization options
116       -o level
117              Select the optimization level.
118              The  optimization  level  0 enables a set of optimization opera‐
119              tions that require minimal effort. There will be no  changes  to
120              image attributes like bit depth or color type, and no recompres‐
121              sion of existing IDAT datastreams.
122              The optimization level  1  enables  a  single  IDAT  compression
123              trial. The trial chosen is what OptiPNG thinks it's probably the
124              most effective.
125              The optimization levels 2 and higher enable multiple  IDAT  com‐
126              pression trials; the higher the level, the more trials.
127              The  behavior  and  the  default value of this option may change
128              across different program versions. Use the option -h to see  the
129              details pertaining to your specific version.
130
131       -f filters
132              Select the PNG delta filters.
133              The  filters  argument  is specified as a rangeset (e.g. -f0-5),
134              and the default filters value depends on the optimization  level
135              set by the option -o.
136              The  filter  values  0, 1, 2, 3 and 4 indicate static filtering,
137              and correspond to the standard PNG filter codes (None, Left, Up,
138              Average  and  Paeth, respectively). The filter value 5 indicates
139              adaptive filtering, whose effect is defined by the libpng(3) li‐
140              brary used by OptiPNG.
141
142       -full  Produce  a full report on IDAT.  This option might slow down the
143              trials.
144
145       -i type
146              Select the interlace type (0-1).
147              If the interlace type 0 is selected, the output image  shall  be
148              non-interlaced (i.e. progressive-scanned). If the interlace type
149              1 is selected, the output image shall be  interlaced  using  the
150              Adam7 method.
151              By default, the output shall have the same interlace type as the
152              input.
153
154       -nb    Do not apply bit depth reduction.
155
156       -nc    Do not apply color type reduction.
157
158       -np    Do not apply palette reduction.
159
160       -nx    Do not apply any lossless image reduction:  enable  the  options
161              -nb, -nc and -np.
162
163       -nz    Do not recode IDAT datastreams.
164              The  IDAT  optimization  operations that do not require recoding
165              (e.g. IDAT chunk concatenation) are still performed.
166              This option has effect on PNG input files only.
167
168       -zc levels
169              Select the zlib compression levels used in IDAT compression.
170              The levels argument is specified as a  rangeset  (e.g.  -zc6-9),
171              and  the  default levels value depends on the optimization level
172              set by the option -o.
173              The effect of this option is defined by the zlib(3) library used
174              by OptiPNG.
175
176       -zm levels
177              Select the zlib memory levels used in IDAT compression.
178              The  levels  argument  is specified as a rangeset (e.g. -zm8-9),
179              and the default levels value depends on the  optimization  level
180              set by the option -o.
181              The effect of this option is defined by the zlib(3) library used
182              by OptiPNG.
183
184       -zs strategies
185              Select the zlib compression strategies used in IDAT compression.
186              The  strategies  argument  is  specified  as  a  rangeset  (e.g.
187              -zs0-3),  and  the default strategies value depends on the opti‐
188              mization level set by the option -o.
189              The effect of this option is defined by the zlib(3) library used
190              by OptiPNG.
191
192       -zw size
193              Select  the  zlib window size (32k,16k,8k,4k,2k,1k,512,256) used
194              in IDAT compression.
195              The size argument can be specified either in bytes (e.g.  16384)
196              or  kilobytes  (e.g.  16k). The default size value is set to the
197              lowest window size that yields an  IDAT  output  as  big  as  if
198              yielded by the value 32768.
199              The effect of this option is defined by the zlib(3) library used
200              by OptiPNG.
201
202   Editing options
203       -snip  Cut one image out of multi-image, animation or video files.
204              Depending on the input format, this may be either the  first  or
205              the most relevant (e.g. the largest) image.
206
207       -strip objects
208              Strip metadata objects from a PNG file.
209              PNG  metadata  is  the information stored in any ancillary chunk
210              except tRNS.  (tRNS represents the alpha channel, which, even if
211              ignored  in  rendering,  is  still a proper image channel in the
212              RGBA color space.)
213              The only option currently supported is -strip all.
214
215   Notes
216       Options may come in any order (except for --), before, after, or alter‐
217       nating  with  file  names. Option names are case-insensitive and may be
218       abbreviated to their shortest unique prefix.
219
220       Some options may have arguments that follow the option name,  separated
221       by whitespace or the equal sign ('='). If the option argument is a num‐
222       ber or a rangeset, the separator may be omitted. For example:
223
224              -out newfile.png  <=>  -out=newfile.png
225              -o3  <=>  -o 3  <=>  -o=3
226              -f0,3-5  <=>  -f 0,3-5  <=>  -f=0,3-5
227
228       Rangeset arguments are cumulative; e.g.
229
230              -f0 -f3-5  <=>  -f0,3-5
231              -zs0 -zs1 -zs2-3  <=>  -zs0,1,2,3  <=>  -zs0-3
232
233

EXTENDED DESCRIPTION

235       The PNG optimization algorithm consists of the following steps:
236
237       1.  Reduce the bit depth, the color type and the color palette  of  the
238           image.   This  step  may reduce the size of the uncompressed image,
239           which, indirectly, may reduce the  size  of  the  compressed  image
240           (i.e. the size of the output PNG file).
241
242       2.  Run  a  suite  of compression methods and strategies and select the
243           compression parameters that yield the smallest output file.
244
245       3.  Store all IDAT contents into a single chunk, eliminating the  over‐
246           head incurred by repeated IDAT headers and CRCs.
247
248       4.  Set the zlib window size inside IDAT to a mininum that does not af‐
249           fect the compression ratio, reducing the memory requirements of PNG
250           decoders.
251
252       Not all of the above steps need to be executed. The behavior depends on
253       the actual input files and user options.
254
255       Step 1 may be customized via the no-reduce options -nb,  -nc,  -np  and
256       -nx.  Step 2 may be customized via the -o option, and may be fine-tuned
257       via the options -zc, -zm, -zs and -zw. Step 3 is always executed.  Step
258       4  is  executed  only  if a new IDAT is being created, and may be fine-
259       tuned via the option -zw.
260
261       Extremely exhaustive searches are not generally expected to yield  sig‐
262       nificant  improvements in compression ratio, and are recommended to ad‐
263       vanced users only.
264
265

EXAMPLES

267       optipng file.png      # default speed
268       optipng -o5 file.png  # slow
269       optipng -o7 file.png  # very slow
270
271

BUGS

273       Lossless image reductions are not completely implemented.   (This  does
274       not  affect  the  integrity of the output files.)  Here are the missing
275       pieces:
276
277              - The color palette reductions are implemented only partially.
278              - The bit depth reductions below 8, for  grayscale  images,  are
279              not implemented yet.
280
281       Encoding of images whose total IDAT size exceeds 2GB is not supported.
282
283       TIFF support is limited to uncompressed, PNG-compatible (grayscale, RGB
284       and RGBA) images.
285
286       Metadata is not imported from the external image formats.
287
288       There is no support for pipes, streams, extended file attributes or ac‐
289       cess control lists.
290
291

SEE ALSO

293       png(5), libpng(3), zlib(3), pngcrush(1), pngrewrite(1).
294
295

STANDARDS

297       The files produced by OptiPNG are compliant with PNG-2003:
298       Glenn  Randers-Pehrson et al.  Portable Network Graphics (PNG) Specifi‐
299       cation, Second Edition.
300       W3C Recommendation 10 November 2003; ISO/IEC IS 15948:2003 (E).
301       http://www.w3.org/TR/PNG/
302
303

AUTHOR

305       OptiPNG is written and maintained by Cosmin Truta.
306
307       This manual page was originally written by Nelson A.  de  Oliveira  for
308       the  Debian  Project.  It was later updated by Cosmin Truta, and is now
309       part of the OptiPNG distribution.
310
311
312
313OptiPNG version 0.7.8             2023-Nov-03                       OPTIPNG(1)
Impressum