51

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?

2
  • 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
    Commented Aug 27, 2012 at 17:49
  • 2
    PNG is lossless. There are existing tools for optimized compression. Should your overly broad question be about the algorithm or format, then there's also the PNG spec
    – mario
    Commented Aug 27, 2012 at 17:52

1 Answer 1

77

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/

6
  • 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
    Commented Feb 25, 2015 at 22:26
  • 1
    @user270014 - You must be inside directory which actually contains that exe file. Use cd C:\path\to\pngquant
    – xZero
    Commented Mar 22, 2015 at 20:56
  • 1
    Is tinyPNG lossy or lossless? Commented Dec 22, 2015 at 19:51
  • 1
    Thank you for the alternative! TinyPNG plus optimization (e.g. image_optim) seems to produce the best results, but pngquant is nice and easy to script.
    – Wilf
    Commented Mar 20, 2016 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 Commented Nov 19, 2018 at 14:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.