I speak here {^_^}

A Simple Bash Script To Mass Compress and Resize Images.

July 28, 2019

Problem Statement:

  • I wanted to compress & resize the large, heavy images of my previous blog, in one go. ( and obviously without much effort)

Solution:

  • Some minimal Bash Script with use of "Convert" command, worked well for me. I founded it to be extremely useful for various other mrdia conversions as well.

#!/bin/sh

mkdir photos-Optimized;
read -p "Convert images from which extension(eg. png):" ext1
read -p "Convert into which extension (eg. png):" ext2
read -p "Dimension to be optimized to, in px (eg. 100x100):" dim

for photos in *.$ext1;	
do 
	convert -verbose "$photos" -quality 85% -resize $dim ./photos-Optimized/"$photos-Optimized.$ext2"; 
done

Thanks a lot Kushal Das for pointing it to me :)