Easiest way to optimise images for web

Photo by Cookie the Pom on Unsplash

Here is how I optimise all pngs and jpgs in a folder for publishing to the web.

To get the tools install with brew or whatever you use.

brew install imagemagick optipng

Then run the following commands to produce optimised images for web sites. This will often reduce the size of the image by 50% or more with no obvious loss of quality for web.

# for jpgs
mogrify -strip -interlace Plane -sampling-factor 4:2:0 -quality 85% *.jpg

# For pngs and bitmaps
optipng *