How does Google's Page Speed lossless image compression work?

后端 未结 9 543
Happy的楠姐
Happy的楠姐 2020-11-30 16:54

When you run Google\'s PageSpeed plugin for Firebug/Firefox on a website it will suggest cases where an image can be losslessly compressed, and provide a link to download th

相关标签:
9条回答
  • 2020-11-30 17:15

    It's a matter of trading encoder's CPU time for compression efficiency. Compression is a search for shorter representations, and if you search harder, you'll find shorter ones.

    There is also a matter of using image format capabilities to the fullest, e.g. PNG8+a instead of PNG24+a, optimized Huffman tables in JPEG, etc.

    Photoshop doesn't really try hard to do that when saving images for the web, so it's not surprising that any tool beats it.

    See

    • ImageOptim (lossless) and
    • ImageAlpha (lossy) for smaller PNG files (high-level description how it works) and
    • JPEGmini/MozJPEG (lossy) for better JPEG compressor.
    0 讨论(0)
  • 2020-11-30 17:19

    For windows there are several drag'n'drop interfaces for easy access.

    https://sourceforge.net/projects/nikkhokkho/files/FileOptimizer/

    For PNG files I found this one for my enjoyment, apparently 3 different tools wrapped in this GIU. Just drag and drop and it does it for you.

    https://pnggauntlet.com/

    It takes time though, try compressing a 1MB png file - I was amazed how much CPU went into this compression comparison which has to be what is going on here. Seems the image is compressed a 100 ways and the best one wins :D

    Regarding the JPG compression I to feel its risky to strip of color profiles and all extra info - however - if everyone is doing it - its the business standard so I just did it myself :D

    I saved 113MB on 5500 files on a WP install today, so its definately worth it!

    0 讨论(0)
  • 2020-11-30 17:24

    There's a very handy batch script that recursively optimizes images beneath a folder using OptiPNG (from this blog):

    FOR /F "tokens=*" %G IN ('dir /s /b *.png') DO optipng -nc -nb -o7 -full %G
    

    ONE LINE!

    0 讨论(0)
提交回复
热议问题