【问题标题】:Image optimisation with Image Magick to improve Page speed on my Wordpress site使用 Image Magick 进行图像优化以提高我的 Wordpress 网站上的页面速度
【发布时间】:2018-07-24 22:18:48
【问题描述】:

我的网站(Wordpress / AVADA 主题)的页面速度存在问题,大部分问题都归结于未优化的图像。我做了一些研究,打算使用 Image Magick。

这是来自 GT Metrix 的报告:

https://gtmetrix.com/reports/www.tinkertravels.com/ac0dMCTe

我有这个脚本来转换我的图像:

convert /Users/james/Desktop/image-magick/santorini.jpg -sampling-factor 4:2:0 -strip -quality 75 -resize 700x466! -interlace JPEG -colorspace RGB -background white -flatten /Users/james/Desktop/image-magick/final/santorini-opt.jpg 

但是,我想将批量图像从一个文件夹(输入)转换为另一个文件夹(输出),然后在每个图像的末尾添加一个 _output?

目前,脚本一次只生成一张同名图像,这并不理想。

任何有关如何更改上述脚本以执行此操作的帮助都会很棒。我希望一旦我用这些替换我的图片,我的页面速度会提高并且不再抱怨这些图片!

谢谢

【问题讨论】:

    标签: html wordpress image optimization imagemagick


    【解决方案1】:

    可以使用 shell 脚本。在设置任何设置或运算符之前,您应该剥离。如果在当前 ImageMagick 上,则如果您想要非线性颜色,请使用 -colorspace sRGB,如果您想要线性颜色,请使用 RGB。如果在非常旧的 IM 版本上,则将它们反转。

    cd path2/inputdirectory
    list=$(ls *.jpg)
    for img in $list; do
    inname=$(convert -ping $img -format "%t" info:)
    convert $img -strip -colorspace RGB -resize 700x466! -background white -flatten -interlace JPEG -sampling-factor 4:2:0 -quality 75 path2/outputdirectory/${inname}.jpg
    done
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-17
      • 2022-06-25
      • 2010-10-16
      • 1970-01-01
      • 1970-01-01
      • 2017-05-18
      相关资源
      最近更新 更多