How to reduce a size of image files

ImageMagick is required

sudo apt-get install imagemagick -y

Reduce image size by 25%

convert image.jpg -resize 25% output.jpg

It will decrese image file size from ~6.1M to ~300K. So pretty fine for website loading

For mass converting run this from the inside folder which contains *.jpg files and find the results under output/ directory

mkdir -p output; for i in `ls |grep -i jpg`; do convert $i -resize 25% ./output/$i; done

Convert files with at least 1M size

mkdir -p output; for i in `du -sh * |grep [0-9]M |awk '{print $2}' |grep JPG`; do convert $i -resize 25% ./output/$i; done

Convert doesn't like spaces, so run the following to get rid of them:

rename 's/ /_/g' *

Similar Posts:

Leave a Reply

Your email address will not be published.