Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
PNG
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Optimizing tools === Various tools are available for optimizing PNG files; they do this by: * (optionally) removing ancillary chunks, * reducing [[color depth]], either: ** use a palette (instead of RGB) if the image has 256 or fewer colors, ** use a smaller palette, if the image has 2, 4, or 16 colors, or ** (optionally) lossily discard some of the data in the original image, * optimizing line-by-line filter choice, and * optimizing DEFLATE compression. ==== Tool list ==== * [[pngcrush]] is the oldest of the popular PNG optimizers. It allows for multiple trials on filter selection and compression arguments, and finally chooses the smallest one. This working model is used in almost every png optimizer. * advpng and the similar advdef utility in the AdvanceCOMP package recompress the PNG IDAT. Different DEFLATE implementations are applied depending on the selected compression level, trading between speed and file size: zlib at level 1, libdeflate at level 2, [[7-zip]]'s [[LZMA]] DEFLATE at level 3, and [[zopfli]] at level 4. * [[pngout]] was made with the author's own deflater (same to the author's zip utility, kzip), while keeping all facilities of color reduction / filtering. However, pngout doesn't allow for using several trials on filters in a single run. It's suggested to use its commercial GUI version, pngoutwin, or used with a [[#Wrapper tools|wrapper]] to automate the trials or to recompress using its own deflater while keep the filter line by line.<ref name="pngoutreusefilter" group="note">Use pngout -f6 to reuse previous filter set</ref> * [[zopfli]]png was also made with its own deflater, zopfli. It has all the optimizing features pngcrush has (including automating trials) while providing a very good, but slow deflater. A simple comparison of their features is listed below. {| class="wikitable" |- ! Optimizer !! Chunk removal !! Color reduction !! Filtering !! Filter reuse<ref group="note">The tools offering such feature could act as a pure re-deflater to PNG files.</ref> !! Multiple trials on filters in a single run !! Deflater<ref group="note">[[zlib]], the reference deflate implementation, compression is suboptimal even at the maximum level. See [[Zopfli]], [[7-zip#Others|zip format in 7-zip]] and [[pngout]].</ref> |- | advpng|| Yes|| No<ref group="note">Not only does advpng not support color reduction, it also fails on images with a reduced colorspace.</ref>|| 0|| No|| N/A<ref group="note">Advpng can only apply filter 0 globally, thus it's neither yes or no, but N/A.</ref>|| (multiple) |- | advdef|| No|| No|| Reuses previous filter set|| Always|| N/A|| (multiple) |- | [[pngcrush]]|| Yes|| Yes|| 0β4 or adaptive|| No|| Yes|| zlib |- | [[pngout]]|| Yes|| Yes|| 0β4 or adaptive|| Yes<ref name="pngoutreusefilter" group="note"/>|| No|| kzip |- | [[zopfli]]png|| Yes|| Yes|| 0β4 or adaptive with 2 different algorithms, or with a brute way|| Yes|| Yes|| zopfli |} Before zopflipng was available, a good way in practice to perform a png optimization is to use a combination of 2 tools in sequence for optimal compression: one which optimizes filters (and removes ancillary chunks), and one which optimizes DEFLATE. Although pngout offers both, only one type of filter can be specified in a single run, therefore it can be used with a [[#Wrapper tools|wrapper tool]] or in combination with [[pngcrush]],<ref name="pngoutreusefilter" group="note"/> acting as a re-deflater, like advdef. ==== Ancillary chunk removal ==== For removing ancillary chunks, most PNG optimization tools have the ability to remove all color correction data from PNG files (gamma, white balance, ICC color profile, standard RGB color profile). This often results in much smaller file sizes. For example, the following command line options achieve this with pngcrush: <code>pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB ''InputFile.png'' ''OutputFile.png''</code> ==== Filter optimization ==== pngcrush, pngout, and zopflipng all offer options applying one of the filter types 0β4 globally (using the same filter type for all lines) or with a "pseudo filter" (numbered 5), which for each line chooses one of the filter types 0β4 using an adaptive algorithm. Zopflipng offers 3 different adaptive method, including a brute-force search that attempts to optimize the filtering.<ref group="note">[pngcrush|pngout] -f OR zopflipng --filters</ref> pngout and zopflipng provide an option to preserve/reuse<ref name="pngoutreusefilter" group="note"/><ref group="note">zopflipng --filters=p</ref> the line-by-line filter set present in the input image. pngcrush and zopflipng provide options to try different filter strategies in a single run and choose the best. The freeware command line version of pngout doesn't offer this, but the commercial version, pngoutwin, does.<ref group="note">Pngoutwin's setting dialog for optimization offers the user a selection of filter strategies.</ref> ==== DEFLATE optimization ==== [[Zopfli]] and the [[7zip#Software development kit|LZMA SDK]] provide [[DEFLATE]] implementations that can produce higher [[Data compression ratio|compression ratio]]s than the [[zlib]] reference implementation at the cost of performance. AdvanceCOMP's <code>advpng</code> and <code>advdef</code> can use either of these libraries to re-compress PNG files. Additionally, [[PNGOUT]] contains its own [[proprietary software|proprietary]] DEFLATE implementation. <code>advpng</code> doesn't have an option to apply filters and always uses filter 0 globally (leaving the image data unfiltered); therefore it should not be used where the image benefits significantly from filtering. By contrast, <code>advdef</code> from the same package doesn't deal with PNG structure and acts only as a re-deflater, retaining any existing filter settings.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
PNG
(section)
Add topic