49

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?

propeller
  • 385
  • 2
  • 9
good_evening
  • 21,085
  • 65
  • 193
  • 298
  • 1
    There are close votes on this question. I was thinking of casting a vote, but it's really hard to justify that when all of the votes are for different reasons. Personally, I think it's off topic. It's not not a real question. There are 2 very real questions. – Wug Aug 27 '12 at 17:49
  • 2
    PNG is lossless. There are existing tools for [optimized compression](http://www.google.de/search?q=png+compression+optimize). Should your overly broad question be about the algorithm or format, then there's also the [PNG spec](http://www.w3.org/TR/PNG/) – mario Aug 27 '12 at 17:52

1 Answers1

75

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/

Ben Zotto
  • 70,108
  • 23
  • 141
  • 204
  • when I tried to execute this exe from command prompt in Windows . it says "'pngquant' is not recognized as an internal or external command, operable program or batch file." do you have any idea on this? – user270014 Feb 25 '15 at 22:26
  • 1
    @user270014 - You must be inside directory which actually contains that exe file. Use cd C:\path\to\pngquant – xZero Mar 22 '15 at 20:56
  • Is tinyPNG lossy or lossless? – Shubham Badal Dec 22 '15 at 19:51
  • @ShubhamBadal: This color reduction process is lossy relative to the original image data. – Ben Zotto Dec 28 '15 at 04:32
  • 1
    Thank you for the alternative! TinyPNG plus optimization (e.g. [`image_optim`](https://github.com/toy/image_optim)) seems to produce the best results, but `pngquant` is nice and easy to script. – Wilf Mar 20 '16 at 18:49
  • 1
    I've made a test. Use a 8-bit PNG file 1.2MB, and tinypng compress it into 300K. It seems it's NOT to turn 24-bit RGB file into a 8 bit one – Ben P.P. Tung Nov 19 '18 at 14:46