V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
explon
V2EX  ›  分享发现

TinyPNG 的压缩 PNG 算法好厉害

  •  
  •   explon · 2014-12-06 17:28:27 +08:00 · 17902 次点击
    这是一个创建于 3428 天前的主题,其中的信息可能已经有所发展或是发生改变。
    https://tinypng.com

    一个项目的 PNG 素材体积减少了 70%,支付带透明度的图像
    12 条回复    2014-12-07 09:57:04 +08:00
    lalawue
        1
    lalawue  
       2014-12-06 17:37:16 +08:00 via Android
    转成索引色了吧
    jun4rui
        2
    jun4rui  
       2014-12-06 17:41:56 +08:00 via Android
    很多PNG压缩以后直接和jpg比尺寸了
    snail1988
        3
    snail1988  
       2014-12-06 18:05:47 +08:00   ❤️ 1
    我以前用imageOptim压缩,感觉不错
    和这个一比弱爆了
    emric
        4
    emric  
       2014-12-06 18:08:38 +08:00
    确实比同类压缩会高一些.

    例如项目中某一张图片:
    PS 8.55 KB / Yahoo Smushit 5.98 KB / CssGaga 3.14 KB / TinyPNG 2.66 KB
    ihacku
        5
    ihacku  
       2014-12-06 18:09:22 +08:00
    aaaa007cn
        6
    aaaa007cn  
       2014-12-06 18:10:57 +08:00
    pngquant 了一下那张 example-orig.png
    默认参数的结果是 15.5 KB
    然后去官网瞄了下 http://pngquant.org/
    >> TinyPNG and Kraken.io — on-line interfaces for pngquant
    唉?TinyPNG 就是用的 pngquant?
    snail1988
        7
    snail1988  
       2014-12-06 18:17:42 +08:00
    @aaaa007cn 貌似真的是pngquant
    GPU
        8
    GPU  
       2014-12-06 18:21:40 +08:00
    意思是可以抛弃 jpg ?
    emric
        9
    emric  
       2014-12-06 18:25:36 +08:00
    @aaaa007cn 不, 还是有差距的. pngquant 3.93 KB.
    rainex
        10
    rainex  
       2014-12-06 18:43:22 +08:00
    How does it work?
    Excellent question! When you upload a PNG (Portable Network Graphics) file, similar colors in your image are combined. This technique is called “quantization”. Because the number of colors is reduced, 24-bit PNG files can be converted to much smaller 8-bit indexed color images. All unnecessary metadata is stripped too. The result: tiny PNG files with 100% support for transparency. Have your cake and eat it too!
    ---------
    是说减少颜色数吧?一般ps或firework输出时有点经验的人都会选择合适的颜色数来减少尺寸的,tinypng比这样处理过的文件还小是么?
    aaaa007cn
        11
    aaaa007cn  
       2014-12-06 21:11:01 +08:00
    @emric
    用的什么参数?即使 --quality 10 结果都有 10KB+ 啊

    @snail1988
    https://news.ycombinator.com/item?id=4168451
    pngquant + optipng + advpng
    TinyPNG 还有 40 美刀的 PS 插件出售……
    pngquant 本身是 BSD 许可的,也有同样 BSD 许可的免费的 PS 插件 SuperPNG
    该说 BSD 许可真好用?Note that both licenses are basically BSD-like; that is, use the code however you like, **as long as you acknowledge its origins**.
    虽然我没在 TinyPNG 网站上看到有提到 pngquant
    pngquant 官网有写 To further reduce file size use optipng or ImageOptim.
    不过 Mozilla 没做 pngquant 和 optipng 合用的测试
    https://wiki.mozilla.org/Mobile/Janus#PNG_Compression
    不知道还能有多少效果

    @rainex
    https://news.ycombinator.com/item?id=4168796
    关键的还是如何进行矢量量化?
    http://pngquant.org/#algorithm
    和 PS save for web 的对比
    http://pngquant.org/vsphotoshop.html

    @GPU
    话说 HN 那串 https://news.ycombinator.com/item?id=4167964 有张构造得很巧妙的图

    我这里唯一能不显著劣化并减少文件尺寸的方法就是另存为 jpg
    efi
        12
    efi  
       2014-12-07 09:57:04 +08:00
    tinypng可能把图中的关键颜色给优化掉。有时需要pngquant手调参数。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1251 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 23:21 · PVG 07:21 · LAX 16:21 · JFK 19:21
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.