Difference between revisions of "Batch jpeg Image Optimization"
(Created page with "==How to compress a jpg image on Centos== The other day I was running a webpagetest on a clients site and the results were telling me to Compress Images Now there was close ...") |
(No difference)
|
Revision as of 20:17, 11 March 2014
Contents
How to compress a jpg image on Centos
The other day I was running a webpagetest on a clients site and the results were telling me to Compress Images
Now there was close to 200 images that needed to be compressed and optimized. That is when I found jpegoptim
You can learn more about jpegoptim, by reading the man page.
Optimize a Single Image
If you are looking to optimize a single image, you would just type
jpegoptim image.jpg
Sample output
image.jpg 710x275 24bit P JFIF [OK] 136256 --> 136256 bytes (0.00%), optimized.
Optimize all JPEG images
You can use the find command to locate all *.jpg images under your current directory by using the following
for x in $(find $PWD -iname "*.jpg"); do jpegoptim $x; done
By default it will optimize all images in their current locations.
Optimize all JPEG images and convert to Progressive
You will also get a boost in load speeds by converting all images to use progressive, meaning that the entire images does not need to load before going to next request.
for x in $(find $PWD -iname "*.jpg"); do jpegoptim --all-progressive $x; done
Now rerun your webpagetest and see the differences
Here are our results - http://www.webpagetest.org/result/140311_HN_10Z0/