用 ImageMagick 优化网页上的 JPEG 图片

在这个无图言X的时代,网页配图已经成了必需。

在同一个时代,网页加载慢上 1 秒,就有一批用户默默地点了右上角的x。

最近给网站配图,设计稿很大,加载慢,于是搜索一番做了如下优化:

convert -strip -interlace Plane -sampling-factor 4:2:0 \  
-quality 85% -define jpeg:dct-method=float \
demo.jpg demo-optimized.jpg  
  • -strip: strip the image of any profiles or comments.
  • -interlace Plane: Use Plane to create a progressive JPEG image.
  • -sampling-factor 4:2:0: This option specifies the sampling factors to be used by the JPEG encoder for chroma downsampling.
  • -quality 85%: JPEG compression level.
  • -define jpeg:dct-method=float: Use the more accurate floating point discrete cosine transform, rather than the default fast integer version.

下面是优化前后对比,我认为画质损失相较于尺寸的大幅减小,可以忽略不计。

优化前,1006.75 KB:

优化后,160.56 KB:

Pei Qing

Read more posts by this author.

Shanghai

Subscribe to edwardtoday

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!