Tools for image optimization and compression

Image optimization is a great way to decrease overall website file size, thus making it load faster and saving bandwidth.
This is a list of tools and Linux commands I use for image optimization and batch resizing.

Linux command line tools

Image bach resizing (resizes images larger than specified size, where width = XXXX and height = YYYY, in pixels), this requires installation of imagemagick:

find . -type f | xargs mogrify -resize 'XXXXxYYYY>'

PNG optimization (install optipng):

find . -name *.png | xargs optipng

exif data removal (install exiv2):

exiv2 -d a *.jpg

Losless JPEG optimization (install jpegoptim):

jpegoptim *.jpg --strip-all

Script for recursive image optimization with jpegoptim in subdirectories:

#!/bin/bash
optimize() {
   jpegoptim *.jpg --strip-all
   for i in *
   do
      if test -d $i
      then
         cd $i
         echo $i
         optimize
         cd ..
      fi
   done
   echo
}
optimize

Online tools

GUI tools

  • http://trimage.org/ – great Linux GUI tool for png and jpeg optimization,
    I love it’s simplicity – just drag and drop the images and that’s it
    trimage-soptimization-creenshot
  • https://imageoptim.com/ – very similar to Trimage, but for Mac platform
  • https://www.xnview.com/ – many advanced options for image batch processing – resizing, converting for Linux, Mac and Windows. I really liked this tool and found it very powerful when I was less familiar with command line and Imagemagick in particular.

Leave a Reply

Your email address will not be published. Required fields are marked *