来自:http://gtmetrix.com/reports/hosting.site.dev.nexwrx.com/OUsrZOCY _include / img / menu-mobile.png可以节省1.0KiB(减少82%)
我尝试过的事情
pngcrush _include/img/menu-mobile.png menu-mobile.png
最佳pngcrush方法= 6(ws 12 fm 5 zl 9 zs 0)= 215 for menu-mobile.pn (减少1.38%的关键块) (文件大小减少0.24%)
当我尝试optipng -o7 _include/img/menu-mobile.png
时
_include / img / menu-mobile.png已经过优化
pngquant --quality=75-80 _include/img/logo
pngpngquant:mempool.c:40:mempool_create:断言`!((uintptr_t)(* mptr +(* mptr) - > used)& 15UL)'失败。 中止
ptquant似乎在一切都失败了(ubuntu 14.04)2.01版任何想法如何以谷歌在.png上的状态减少82%?
答案 0 :(得分:3)
谷歌删除了iTXt和tEXt块,节省了大约1050个字节,并将像素从32位/像素RGBA减少到4位/像素索引,节省了更多的字节:
$ pngcheck -v menu-mobile.png
File: menu-mobile.png (1265 bytes)
chunk IHDR at offset 0x0000c, length 13
16 x 32 image, 32-bit RGB+alpha, non-interlaced
chunk iTXt at offset 0x00025, length 1001, keyword: XML:com.adobe.xmp
uncompressed, no language tag
no translated keyword, 980 bytes of UTF-8 text
chunk tEXt at offset 0x0041a, length 25, keyword: Software
chunk IDAT at offset 0x0043f, length 158
zlib: deflated, 4K window, maximum compression
chunk IEND at offset 0x004e9, length 0
No errors detected in menu-mobile.png (5 chunks, 38.2% compression).
$ pngcheck -v menu-mobile-opt.png
File: menu-mobile_opt.png (216 bytes)
chunk IHDR at offset 0x0000c, length 13
16 x 32 image, 4-bit palette, non-interlaced
chunk PLTE at offset 0x00025, length 36: 12 palette entries
chunk tRNS at offset 0x00055, length 11: 11 transparency entries
chunk IDAT at offset 0x0006c, length 88
zlib: deflated, 512-byte window, default compression
chunk IEND at offset 0x000d0, length 0
No errors detected in menu-mobile_opt.png (5 chunks, 15.6% compression).
Pngcrush可以通过将像素减少到16位/像素Gray-alpha来做得更好:
$ pngcrush -s -reduce -rem text menu-mobile.png menu-mobile-pc.png
$ pngcheck -v menu-mobile-pc.png
File: menu-mobile-pc.png (175 bytes)
chunk IHDR at offset 0x0000c, length 13
16 x 32 image, 16-bit grayscale+alpha, non-interlaced
chunk IDAT at offset 0x00025, length 118
zlib: deflated, 2K window, maximum compression
chunk IEND at offset 0x000a7, length 0
No errors detected in menu-mobile-pc.png (3 chunks, 82.9% compression).
在这种情况下,包含压缩像素数据的IDAT块比google的结果大30个字节,但由于Gray-alpha颜色类型不对,这个因素被抵消了需要PLTE(36字节数据加12字节块开销)和tRNS(11字节数据+ 12字节开销)块。对于尺寸较大的图像,这种权衡可能会有所不同。