Home Image optimisation with Image Magick to improve Page speed on my Wordpress site

# Image optimisation with Image Magick to improve Page speed on my Wordpress site

John
1#
John Published in 2018-02-14 11:00:44Z
 I am having issues with the page speed of my site (Wordpress / AVADA theme), and the majority of the issues are down to images not being optimised. I have done a bit of research and going to use Image Magick. Here is a report from GT Metrix: https://gtmetrix.com/reports/www.tinkertravels.com/ac0dMCTe I have this script for converting my images: 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  However I want to convert bulk images from one folder (input) to another (output) then add a _output at the end of each image? At the moment the script does one image at a time with the same name, which isn’t ideal. Any help on how I can change the above script to do this would be great. I am hoping once I replace my images with these my page speed will increase and stop complaining about the images! Thanks
fmw42
2#
 A shell script is possible. You should strip before setting any settings or operators. If on current ImageMagick, then use -colorspace sRGB if you want non-linear color and RGB if you want linear color. If on very old IM versions then reverse them. 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