Optipng - 优化 PNG 图像

PNG 即 Portable Network Graphic 的简称,PNG 图像是一种无损压缩图像文件格式。因为网络传输的需要,我们总是希望 PNG 图像的容量能够小些、小些、再小些。要优化 PNG 图像,可以使用 Optipng 这个专门的 PNG 图像优化工具。

安装 Optipng

可使用下列命令来安装 Optipng:

  • Debian/Ubuntu:$ sudo apt-get install optipng
  • Fedora:# yum install optipng
  • Archlinux:# pacman -S optipng

Optipng 用法

Optipng 是命令行工具,直接在其后追加所需优化的 PNG 图像即可 (当然,给原文件备份是一种好习惯):

optipng desktop.png

如下图所示,原图 desktop.png 为 857 KB,经 Optipng 优化后为 677 KB,优化的效果还是比较明显的。

Optipng

可以 man optipng 详细了解 Optipng 的优化参数。

值得一提的是,Optipng 也可以将其他图像格式 (如 bmp、gif、tiff) 转换成已优化的 PNG 图像。

Optipng

更新

读者推荐的其他 PNG 优化工具,包括 pngrewritepngcrushpngout (win32)、pngnq 等。

Read More:

  • No related posts

27 Comments

  1. 1 shellex Commented @ 2008-07-21 10:13Reply to this comment

    一般的png好像总是偏大一点,比起别的格式

  2. 2 Aspirin Commented @ 2008-07-21 10:16Reply to this comment

    @Toy

    这个是Luxi mono字体吧?你的UI字体好像也是Luxi sans

    感觉你的Luxi字体处理比较好看。

    能问一下hinting autohint hintstyle都是怎么设置的么?

  3. 3 fcicq Commented @ 2008-07-21 10:31Reply to this comment

    pngrewrite, pngcrush, pngout(为啥是 win32 的...)

  4. 4 Toy Commented @ 2008-07-21 10:43Reply to this comment

    @Aspirin: 我在 .Xdefaults 中加入了这几行内容:

    Xft.dpi: 96 Xft.antialias: 1 Xft.hinting: 0 Xft.hintstyle: hintnone Xft.autohint: 0 Xft.rgba: rgb

    @fcicq: 好推荐。

  5. 5 lon Commented @ 2008-07-21 11:26Reply to this comment

    体积偏大这很正常,质量与体积的矛盾

  6. 6 lh Commented @ 2008-07-21 11:39Reply to this comment

    这样图像质量会不会下降?

  7. 7 Fish Commented @ 2008-07-21 12:15Reply to this comment

    同意 应该会下降的

  8. 8 NONE Commented @ 2008-07-21 13:07Reply to this comment

    OptiPNG is a PNG optimizer that recompresses image files to a smaller size without losing any information

  9. 9 ayanamist Commented @ 2008-07-21 13:20Reply to this comment

    可能不会下降。看输出的内容,好像只是尝试不同压缩参数下的压缩后大小,应该不会影响文件本身的质量。

  10. 10 redguardtoo Commented @ 2008-07-21 13:28Reply to this comment

    试试pngnq,楼主的图像经过处理后由96K变为20K, 见http://www.flickr.com/photos/33393464@N00/2687569159/

  11. 11 Toy Commented @ 2008-07-21 15:00Reply to this comment

    经 optipng 优化后,图像效果基本上跟原图差不多。虽然 pngnq 压缩效果惊人,但图像效果跟原图差别颇大。

  12. 12 redguardtoo Commented @ 2008-07-21 15:26Reply to this comment

    质量不会比fireworks 8的效果更差,取决于你压缩选项,如果我用默认的256色,90K压缩到28K。 参考: http://cid-53618063fe206e9a.skydrive.live.com/browse.aspx/Public?uc=3 optipng-16clr.png 18K optipng-256clr.png 28K optipng.png 90K

    关于图像取样算法导致的图像质量差异,google neuquant

  13. 13 kpt Commented @ 2008-07-21 18:56Reply to this comment

    有个问题 既然是无损压缩图像 为什么使用有些工具优化后图像质量会下降?

  14. 14 redguardtoo Commented @ 2008-07-21 19:23Reply to this comment

    png有png24(真彩)与png8(256色)两种格式。

    真彩取样为256色后质量当然可能有下降。

    png8的优点在于无杂波(和jpg比较),支持全通道alpha透明。所以多用于logo或者图标(颜色数较少,无边缘锯齿)。

  15. 15 lon Commented @ 2008-07-21 20:29Reply to this comment

    我是很喜欢png的,和jpg比,就像MP3和FLAC比一样,差别很明显

  16. 16 Fwolf’s Blog » Blog Archive PNG图片压缩工具 - Fwolf's Blog Pingbacked @ 2008-07-21 22:52Reply to this comment

    [...] Optipng - 优化 PNG 图像 [...]

  17. 17 Fwolf Commented @ 2008-07-21 22:58Reply to this comment

    faint, ping过来居然是这么多乱码。。。

  18. 18 Daniel King Commented @ 2008-07-22 12:42Reply to this comment

    to lon: 照片这种颜色很复杂的图片还是jpg的好

  19. 19 kergee Commented @ 2008-07-22 16:36Reply to this comment

    桌面截图还是用png的合适(特别是文字比较多的时候),在相近的图像质量下png的反较jpg的小

  20. 20 Rainux Commented @ 2008-07-22 16:42Reply to this comment

    JPEG 只适合照片这类颜色数量极多的图片,PNG 则只有在颜色数相对较少的情况下有很好的质量/体积比。

  21. 21 SecretZero Commented @ 2008-07-23 3:43Reply to this comment

    不是图形工具,用起来很费劲阿。

  22. 22 SecretZero Commented @ 2008-07-23 3:47Reply to this comment

    变成png跟jpg,同样的画质,jpg还是比较小的。

  23. 23 shizhao Commented @ 2008-07-24 22:30Reply to this comment

    使用png,不如使用svg

  24. 24 Galaxy Commented @ 2008-07-27 22:11Reply to this comment

    开什么玩笑,png24不就是真彩的吗,还支持8位透明度。

    按默认参数,optipng对24位或8位的bmp和png都不会做有损处理,那来的损失?

  25. 25 asd Commented @ 2008-07-30 19:58Reply to this comment

    optipng 除了嘗試不同的壓縮方法以外, 也會自動調整色盤, 要是有張十六色的圖用真彩去存, 那麼用 optipng 就會有很大的效果, 因為他會把那張圖用 16色去存。 順便一題,optipng 不會造成影像品質的損失 搭配 advpng 用會更有效果

  26. 26 lulu Commented @ 2009-07-13 9:46Reply to this comment

    还有用AdvPNG...这个也不错的!

  27. 27 asins Commented @ 2009-09-22 11:28Reply to this comment

    值得一提的是,Optipng 也可以将其他图像格式 (如 bmp、gif、tiff) 转换成已优化的 PNG 图像。

    为什么不支持jpg,郁闷,