resize image from command line

Using convert command to change size of a picture or many

convert -resize 50% one.jpg two.jpg
convert -size 120×120 one.jpg -resize 120×120 out.jpg

And we can create some script to change all the picture in a directory
#nano scriptchangeimage

#!/bin/bash
INPUT=$1
for i in *.JPG; do
if [ -e “$i”]; then
file=’basename “$i” .JPG’
convert “$i” -resize “$1” “$file.resize.JPG”
fi
done

change the file property into execute mode
#chmod 755 scriptchangeimage
Use it like this
#./scriptchangeimage 50%
And now all picture went 50% smaller.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.