Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does tinypng.org compress PNG files? [closed]

http://tinypng.org/ is a great service, they optimized my png images by ~67%. How does their service work? How can they minimize size and quality of pictures still remains the same?

like image 948
good_evening Avatar asked Aug 27 '12 17:08

good_evening


People also ask

How are PNG files compressed?

PNG uses DEFLATE, a non-patented lossless data compression algorithm involving a combination of LZ77 and Huffman coding. Permissively-licensed DEFLATE implementations, such as zlib, are widely available.

Does PNG get compressed?

Unlike JPEG files that get terrible picture artifacts with heavy compression, PNG's use lossless compression, meaning compression doesn't impact image quality. There's initial compression done in the export stage, but you can use further methods to reduce the PNG file size more.

Does PNG lose quality when compressed?

The biggest advantage of PNG over JPEG is that the compression is lossless, meaning there is no loss in quality each time it is opened and saved again. PNG also handles detailed, high-contrast images well.

How is PNG lossless compression?

PNG compression is almost identical to ZIPping files. You can compress them more or less but you get the exact file back when it decompresses -- that's what makes it lossless.


1 Answers

The answer's right on that web page:

When you upload a PNG (Portable Network Graphics) file, similar colours in your image are combined. This technique is called “quantisation”. Because the number of colours is reduced, 24-bit PNG files can be converted to much smaller 8-bit indexed colour images. All unnecessary metadata is stripped too. The result: tiny 8-bit PNG files with 100% support for transparency. Have your cake and eat it too!

It turns 24-bit RGB files into palettized 8-bit ones. You lose some color depth, but for small images it's often imperceptible.

You can do the same thing manually on the command line with this awesome tool: http://pngquant.org/

like image 77
Ben Zotto Avatar answered Oct 09 '22 03:10

Ben Zotto