Pngcrush: Difference between revisions
m →See also: removed redirect |
Citation bot (talk | contribs) Altered isbn. Upgrade ISBN10 to 13. | Use this bot. Report bugs. | Suggested by Dominic3203 | Category:Free graphics software | #UCB_Category 25/45 |
||
(76 intermediate revisions by 58 users not shown) | |||
Line 1: | Line 1: | ||
{{Short description|Command-line PNG optimiser}} |
|||
{{lowercase|title=pngcrush}} |
{{lowercase|title=pngcrush}} |
||
{{Infobox software |
|||
{{Infobox_Software | |
|||
| name = pngcrush |
|||
| screenshot = Pngcrush screenshot.png |
|||
| caption = pngcrush 1.8.13 |
|||
| developer = Glenn Randers-Pehrson |
|||
| latest_release_version = 1.8.13<ref>{{cite web|url=https://pmt.sourceforge.io/pngcrush/ChangeLog.html|title=pngcrush changelog|accessdate=27 July 2018|via=[[SourceForge]]}}</ref> |
|||
latest_release_version = 1.7.4 | |
|||
| latest_release_date = {{release date and age|2017|08|29|df=yes}}<ref>{{cite web|url=https://sourceforge.net/projects/pmt/files/pngcrush/1.8.13/|title=PNG and MNG tools - Browse /pngcrush/1.8.13 at SourceForge.net|via=[[SourceForge]]|date=29 August 2017|accessdate=27 July 2018}}</ref> |
|||
latest_release_date = {{release date|2009|10|24}} | |
|||
| operating_system = [[Cross-platform]] |
|||
| programming language = [[C (programming language)|C]] |
|||
| genre = [[Image compression|Image optimizer]] |
|||
| license = Similar to [[libpng License]] |
|||
| website = {{URL|https://pmt.sourceforge.io/pngcrush/}} |
|||
}} |
}} |
||
'''pngcrush''' is a [[free software|free]] |
'''pngcrush''' is a [[free software|free]] and [[open-source software|open-source]] [[Command-line interface|command-line]] utility for optimizing [[Portable Network Graphics|PNG]] image files. It reduces the size of the file [[Lossless data compression|losslessly]]{{snd}} that is, the resulting "crushed" image will have the same quality as the source image. |
||
The main purpose of pngcrush is to reduce the size of the PNG [[Portable Network Graphics#Critical chunks|IDAT data stream]] by trying various combinations of compression methods and delta filters. It can also be used for various manipulations of PNG images, such as changing the [[color depth|bit depth]], removing unwanted [[Portable Network Graphics#Ancillary chunks|ancillary chunks]], or adding certain chunks including gAMA, tRNS, iCCP, and textual chunks. |
|||
pngcrush offers an optional "-brute" argument which attempts to [[brute-force search|brute force]] the crush when set: rather than use one of a few common methods to crush the file, it will try all of them. |
|||
==Main operation== |
==Main operation== |
||
The main use of pngcrush is for reducing the size of the image data contained in the IDAT section. |
|||
The main use of pngcrush is for reducing the size of the image data contained in the IDAT section. PNG uses [[DEFLATE (algorithm)|DEFLATE]] compression which can vary in speed and compression ratio, from nearly no compression at all but at very high speed to the very good compression ratio, albeit at a lower speed. The PNG compressors built into many paint programs may not always apply the maximum amount of compression possible, and it is on images from these programs that pngcrush performs best. |
|||
The pixel data in a PNG file is compressed using [[LZ77]] algorithm (which tries to find repeated byte sequences in the source data), and then further compressed with [[Huffman coding|Huffman algorithm]]. This combination is referred to as [[Deflate|deflate compression]]. Before compressing, non-destructive delta filters are applied on the pixel data. |
|||
pngcrush can be told to generate a "crushed" file from an unoptimized one by using the following format on the command line: |
|||
There are five possible filter types that can be specified separately on each scan line and several possible strategies for searching LZ77 matches. Thus, there are a very large number of different combinations for how the image can be compressed. Which combination gives the best compression will depend on the individual image's properties.<ref>{{cite web|title=A guide to PNG optimization|url=http://optipng.sourceforge.net/pngtech/optipng.html|accessdate=31 July 2010|author=Cosmin Truta|date=10 May 2008}}</ref> |
|||
pngcrush imageIn.png imageOut.png |
|||
pngcrush compresses the image with multiple different combinations and then stores the smallest of the resulting files.<ref>{{cite web|last=Whedon|first=David|title=man pngcrush|url=http://pwet.fr/man/linux/commandes/pngcrush|accessdate=31 July 2010}}</ref> Since it is not possible to go through all the combinations, pngcrush uses heuristics to choose the methods to try. |
|||
⚫ | |||
⚫ | |||
By default, pngcrush uses just a few common methods to crush the file. The optional "-brute" argument can be used for [[brute-force search|brute force]] crushing, which will try 176 different crushing methods on version 1.8.12 and later or 148 crushing methods on versions 1.7.45 through 1.8.11. |
|||
pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB ''InputFile.png'' ''OutputFile.png'' |
|||
⚫ | |||
⚫ | Since most graphics software embed the extra color-correction data, which is normally not needed, removing it can produce file sizes that are up to 40% smaller than the original. pngcrush, when told, will also losslessly reduce the bit-depth of images or apply a [[Indexed color|color palette]] when possible if doing so results in a smaller file size. |
||
⚫ | One of pngcrush's features is the ability to remove all the color-correction data ([[Gamma correction|gamma]], [[white balance]], [[ICC color profile]], standard [[RGB]] color profile) from PNG files.<ref>{{cite web|last1=Sivonen|first1=Henri|title=The Sad Story of PNG Gamma "Correction"|url=http://hsivonen.iki.fi/png-gamma/|date=21 April 2003|accessdate=8 September 2017}}</ref> |
||
⚫ | Since most graphics software embed the extra color-correction data, which is normally not needed,{{according to whom|date=March 2017}} removing it can produce file sizes that are up to 40% smaller than the original. pngcrush, when told, will also losslessly reduce the bit-depth of images or apply a [[Indexed color|color palette]] when possible if doing so results in a smaller file size. All ancillary chunks and text chunks can be removed. |
||
All ancillary chunks and text chunks can be removed using the following options: |
|||
pngcrush -rem gAMA -rem alla -rem text ''InputFile.png'' ''OutputFile.png'' |
|||
==Image manipulation== |
==Image manipulation== |
||
pngcrush can be used to change the color encoding of an image. For example, if an image contains 10 colors but has a color palette of 256 entries (8-bit), pngcrush can be used to reduce the color palette to a 4-bit one and truncate the palette to 10 entries |
pngcrush can be used to change the color encoding of an image. For example, if an image contains 10 colors but has a color palette of 256 entries (8-bit), pngcrush can be used to reduce the color palette to a 4-bit one and truncate the palette to 10 entries. |
||
⚫ | pngcrush can also change the color type of the image. For a true-color image, changing the color type from 2 to 0 converts it to greyscale. Greyscale images are generally smaller than truecolor images because, in addition to the optional [[Alpha compositing|alpha channel]], only one 8-bit channel is used per pixel rather than three. Greyscale images are also generally smaller than paletted images because they do not need to define a [[Palette (computing)|color palette]]. For a truecolor-alpha image, changing the color type from 6 to 2 removes the alpha channel. |
||
pngcrush -bit_depth 4 -plte_len 10 ''image1.png'' ''image2.png'' |
|||
⚫ | pngcrush can also change the color type of the image. For a true-color image, changing the color type from 2 to 0 |
||
==Chunk and metadata manipulation== |
==Chunk and metadata manipulation== |
||
PNG images contain chunks with information about the image, such as its resolution (the phys chunk), the time it was last modified (the tIME chunk), and textual metadata (the text chunk and its variants). With pngcrush, a user can edit or remove those ancillary chunks |
PNG images contain chunks with information about the image, such as its resolution (the phys chunk), the time it was last modified (the tIME chunk), and textual metadata (the text chunk and its variants). With pngcrush, a user can edit or remove those ancillary chunks. |
||
⚫ | |||
pngcrush -res 96 -rem time -text b "Software" "pngcrush" image1.png image2.png |
|||
{{Portal|Free and open-source software}} |
|||
The above command sets the image resolution to 96 [[Dots per inch|dpi]], removes the timestamp, and writes a textual metadata chunk describing pngcrush as the creation software of the image. |
|||
⚫ | |||
{{portal|Free software|Free Software Portal Logo.svg}} |
|||
Similar PNG compression programs include: |
|||
* [[PNGOUT]] |
* [[PNGOUT]] |
||
* [[ |
* [[Zopfli]] |
||
* [[Image-Pngslimmer]] |
|||
==References== |
==References== |
||
{{Reflist}} |
|||
⚫ | |||
* Khalid Sayood, ''Lossless compression handbook'', Academic Press, 2003, ISBN 0126208611, pp. 386-388 |
|||
===Further reading=== |
|||
⚫ | |||
* {{Cite book |first=Khalid |last=Sayood |title=Lossless Compression Handbook |publisher=Academic Press |year=2003 |isbn=0-12-620861-1 |pages=386–388}} |
|||
==External links== |
==External links== |
||
* |
* {{Official website|https://pmt.sourceforge.io/pngcrush/}} |
||
*[http://gnuwin32.sourceforge.net/packages/pngutils.htm pngutils for the Win32 console] |
* [http://gnuwin32.sourceforge.net/packages/pngutils.htm pngutils for the Win32 console] |
||
* [https://github.com/cloudflare/pngcrush pngcrush fork] with optimized [[zlib]] using [[SSE2]]+ instructions, [https://blog.cloudflare.com/cloudflare-fights-cancer/ developed] by [[CloudFlare]] |
|||
*[http://www.neilturner.me.uk/2005/02/05/quickly_compress_png_images.html Quickly compress PNG images] - Adds the "crush" option to the context menu of [[Windows Explorer]]. |
|||
[[Category:Free graphics software]] |
[[Category:Free graphics software]] |
||
[[Category:Free data compression software]] |
[[Category:Free data compression software]] |
||
[[Category:Free software programmed in C]] |
[[Category:Free software programmed in C]] |
||
[[Category:Portable Network Graphics]] |
|||
[[de:pngcrush]] |
Latest revision as of 14:32, 29 November 2024
Developer(s) | Glenn Randers-Pehrson |
---|---|
Stable release | |
Repository | |
Written in | C |
Operating system | Cross-platform |
Type | Image optimizer |
License | Similar to libpng License |
Website | pmt |
pngcrush is a free and open-source command-line utility for optimizing PNG image files. It reduces the size of the file losslessly – that is, the resulting "crushed" image will have the same quality as the source image.
The main purpose of pngcrush is to reduce the size of the PNG IDAT data stream by trying various combinations of compression methods and delta filters. It can also be used for various manipulations of PNG images, such as changing the bit depth, removing unwanted ancillary chunks, or adding certain chunks including gAMA, tRNS, iCCP, and textual chunks.
Main operation
[edit]The main use of pngcrush is for reducing the size of the image data contained in the IDAT section.
The pixel data in a PNG file is compressed using LZ77 algorithm (which tries to find repeated byte sequences in the source data), and then further compressed with Huffman algorithm. This combination is referred to as deflate compression. Before compressing, non-destructive delta filters are applied on the pixel data.
There are five possible filter types that can be specified separately on each scan line and several possible strategies for searching LZ77 matches. Thus, there are a very large number of different combinations for how the image can be compressed. Which combination gives the best compression will depend on the individual image's properties.[3]
pngcrush compresses the image with multiple different combinations and then stores the smallest of the resulting files.[4] Since it is not possible to go through all the combinations, pngcrush uses heuristics to choose the methods to try.
By default, pngcrush uses just a few common methods to crush the file. The optional "-brute" argument can be used for brute force crushing, which will try 176 different crushing methods on version 1.8.12 and later or 148 crushing methods on versions 1.7.45 through 1.8.11.
Reducing file size by removing color-correction data
[edit]One of pngcrush's features is the ability to remove all the color-correction data (gamma, white balance, ICC color profile, standard RGB color profile) from PNG files.[5]
Since most graphics software embed the extra color-correction data, which is normally not needed,[according to whom?] removing it can produce file sizes that are up to 40% smaller than the original. pngcrush, when told, will also losslessly reduce the bit-depth of images or apply a color palette when possible if doing so results in a smaller file size. All ancillary chunks and text chunks can be removed.
Image manipulation
[edit]pngcrush can be used to change the color encoding of an image. For example, if an image contains 10 colors but has a color palette of 256 entries (8-bit), pngcrush can be used to reduce the color palette to a 4-bit one and truncate the palette to 10 entries.
pngcrush can also change the color type of the image. For a true-color image, changing the color type from 2 to 0 converts it to greyscale. Greyscale images are generally smaller than truecolor images because, in addition to the optional alpha channel, only one 8-bit channel is used per pixel rather than three. Greyscale images are also generally smaller than paletted images because they do not need to define a color palette. For a truecolor-alpha image, changing the color type from 6 to 2 removes the alpha channel.
Chunk and metadata manipulation
[edit]PNG images contain chunks with information about the image, such as its resolution (the phys chunk), the time it was last modified (the tIME chunk), and textual metadata (the text chunk and its variants). With pngcrush, a user can edit or remove those ancillary chunks.
See also
[edit]References
[edit]- ^ "pngcrush changelog". Retrieved 27 July 2018 – via SourceForge.
- ^ "PNG and MNG tools - Browse /pngcrush/1.8.13 at SourceForge.net". 29 August 2017. Retrieved 27 July 2018 – via SourceForge.
- ^ Cosmin Truta (10 May 2008). "A guide to PNG optimization". Retrieved 31 July 2010.
- ^ Whedon, David. "man pngcrush". Retrieved 31 July 2010.
- ^ Sivonen, Henri (21 April 2003). "The Sad Story of PNG Gamma "Correction"". Retrieved 8 September 2017.
Further reading
[edit]- Souders, Steve (2009). Even Faster Web Sites: Essential Knowledge for Frontend Engineers. O'Reilly Media. p. 142. ISBN 978-0-596-52230-8.
- Sayood, Khalid (2003). Lossless Compression Handbook. Academic Press. pp. 386–388. ISBN 0-12-620861-1.
External links
[edit]- Official website
- pngutils for the Win32 console
- pngcrush fork with optimized zlib using SSE2+ instructions, developed by CloudFlare