Easiest way to optimise images for web

Darragh O'Riordan - Nov 27 '22 - - Dev Community

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
Enter fullscreen mode Exit fullscreen mode

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 *
Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player