JPEG 压缩和渐进式 JPEG

JPEG compression and progressive JPEG

我有一个高分辨率的基线 JPEG,我想将我的网站从 6MB 压缩到 +- 300kb 并使其渐进。

现在我知道如何同时使用 photoshop 和在线工具或 gulp/grunt 任务进行压缩。

我想知道图像的最佳顺序是什么(最佳质量):

  1. 先对原图进行压缩,再进行渐进

  2. 先做渐进式再压缩图片

  3. 没关系:)

至于质量,这很难判断,因为它取决于图像——您没有显示图像。如果您想要将尺寸缩小 20 倍,那么您必须预料到质量会有所下降。所以,我会让你评估质量。关于处理...

您可以使用 ImageMagick 同时执行这两项操作,它安装在大多数 Linux 发行版上,并且适用于 macOS 和 Windows.

检查输入图像大小为 6MB:

ls -lrht input.jpg

-rw-r--r--  1 mark  staff   6.0M  2 Dec 16:09 input.jpg

检查输入图像是否交错:

identify -verbose input.jpg | grep -i interlace
Interlace: None

转换为 progressive/interlaced JPEG 且大小为 300kB:

convert input.jpg -interlace plane -define jpeg:extent=300KB result.jpg 

检查大小现在低于 300kB:

ls -lhrt result.jpg

-rw-r--r--@ 1 mark  staff   264K  2 Dec 16:11 result.jpg

检查现在交错:

identify -verbose result.jpg | grep -i interlace
Interlace: JPEG

你也可以使用比 ImageMagick:

更轻的 jpegtran
jpegtran -copy none -progressive input.jpg output.jpg