Image compression is the process of reducing the weight on an image by decreasing its size and encoding less information or encoding it more efficiently,ideally without affecting or lowering the picture’s quality, in order to improve file-sharing, downloading, and viewing speeds.
Mass Image Compressor is a free point and shoot batch image compressor and converter tool for Web site optimization, photographers, HTML game creators and casual Windows users.
Converseen is a free and open source, cross-platform GUI software for batch image conversion and resizing. You can use it to convert, compress, resize, rotate, and flip multiple images at once with a single click.
ImageMagick is a free and open-source cross-platform software suite for displaying, creating, converting, modifying, and editing raster images. It is designed for batch processing of images. Let’s see some examples.
Installation. Windows (ImageMagick, Download, Windows Binary Release), macOS (brew install imagemagick, brew install ghostscript), and Linux (sudo apt install imagemagick).
Display a single file/all the files in a directory: display myImage.jpg / display *.png.
Flip image in the vertical/horizontal direction: display -flip myImage.jpg / display -flop myImage.jpg.
Convert [a single file/all the files in a directory] between image formats: convert bridge.jpg -monochrome bridgeMonochrome.jpg (it transforms bridge.jpg from color to black and white) / convert *.jpg *.png (it converts multiples files from jpg to png) / convert *.png *.jpg (and vice-versa).
convert’s syntax format is as follows: convert inputFileName [options] outputFileName
Improve brightness/contrast of the image: convert -brightness-contrast 20x8 myImage.jpg output.jpg. It increases the brightness by 20 and the contrast by 8.
Resize to specific dimensions and keep the aspect ratio: convert myImage.jpg -resize 800 output.jpg (it resizes myImage.jpg to 800 pixels wide), convert myImage.jpg -resize “50%” Backup/resizeMyImage.jpg (it resizes myImage.jpg by 30% and save it in another folder), mogrify -path Backup/ -resize 800 *.jpg (it takes all the JPEG files in the current directory, resize them to 800 pixels wide, and save then in the Backup directory).
Blur images: convert -blur 2x3 myImage.jpg output.jpg
Add text: convert -font Helvetica -fill white -gravity SouthEast -annotate +0+10 ‘The bridge’ bridge.jpg output.jpg (gravity SouthEast moves the text to the bottom right of the image, font renders text with a particular font, fill defines the color).
Swirl images pixels about the center: convert -swirl 180 myImage.jpg output.jpg
We can use scripts for batch-processing of the images.
for j in *.jpg
do
convert -monochrome "$j" altered_"$j"
done
Add a border: convert -border 1x1 -bordercolor “#000000” sourceImage.jpg newImage.jpg
Other options are FastStone Image Viewer (Tools, Batch Convert Selected Images) and Irfan View (File, Batch Conversion/Rename).
jpegoptim is an open source, command-line utility to optimize and compress jpegs/jpgs with or without quality loss
du -h | sort -h # Display the disk usage of files and directories in human-readable format and sort them by size
find . -type f -name "*.jpg" | xargs jpegoptim --max=85 -f --strip-all
find . -type f -name "*.jpg" | xargs -I {} mogrify -resize 2480x3508 {} && jpegoptim --max=85 -f --strip-all {} # To change the dimensions of the images, we use a tool mogrify from the ImageMagick suite.
It leverages find to locate all JPEG files recursively (finds all files with a jpg extension in the current directory and its subdirectories) and xargs (it pipes the list of found files to xargs with passes them as arguments to jpegoptim) to pass those files to jpegoptim for compression.
The arguments are: ‐‐max = 85 (it sets the maximum quality factor or the compression level to 85), ‐f (forces optimization even if the file seems already optimized), ‐‐strip-all (it strips all metadata from the files).
Credits: List of Freeware, 12 Best Free Batch Image Optimizer Software For Windows