Recommendation for compressing JPG files with ImageMagick

后端 未结 10 1310
有刺的猬
有刺的猬 2020-12-04 04:10

I want to compress a JPG image file with ImageMagick but can\'t get much difference in size. By default the output size is bigger than the input. I don\'t know why, but afte

10条回答
  •  再見小時候
    2020-12-04 05:09

    I'm using the Google Pagespeed Insights image optimization guidelines, and for ImageMagick they recommend the following:

    -sampling-factor 4:2:0
    -strip
    -quality 85 [it can vary, I use range 60-80, lower number here means smaller file]
    -interlace
    -colorspace RGB

    Command in ImageMagick:

    convert image.jpg -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG -colorspace RGB image_converted.jpg
    

    With these options I get up to 40% savings in JPEG size without much visible loss.

提交回复
热议问题