# How to resize multiple images in Ubuntu
Thu May 10 2018
If you've ever worked with images on a computer you probably had to resize it in order to use it online. Here is an easy way to resize multiple images at once to a any percentage of their original sizes using the terminal in Ubuntu.
You would need some basic terminal skills to use this tutorial.
# 1. Open a terminal window (Ctrl-Alt-T) and change directory where your images are stored, e.g. cd Pictures/my-images
.
# 2. Create a script called resize_images.sh
and paste the following code into it:
SIZE=$1
FOLDER=${PWD##*/}
SMALLERFOLDER=../$FOLDER-$SIZE
mkdir $SMALLERFOLDER
echo 'Made a new directory to contain the resized images at '$SMALLERFOLDER
for f in `find . -regex ".*\.\(jpg\|gif\|png\|jpeg\|JPG\)"`
do
echo "Resizing - $f to $SIZE%"
convert $f -resize $SIZE% $SMALLERFOLDER/$f
done
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
# 3. Close the script and type ./resize_images.sh 50%
into your terminal using the percantage you would prefer it to be resized to.
The script might not run due to a permissions error. To fix this, simply type
chmod +x resize_images.sh
into your terminal.
# 4. Well done! Your images should now be resized and stored in a folder at the same level as your folder that contained your images with a suffix of the percentage your resized it to, e.g. at ../my-images-50
.
# 5. If some of your images don't appear in the folder, check if those images'
file types are present in the list of file types in the script. You can simply
add the file type to the list before the last \)
, e.g. \|gnf
.
# 6. The convert
program that we're using to resize the images can also be used for many other useful image-related tasks. Type man convert
to see if there are any other ways you could transform your bunch of images.
Newsletter
If you'd like to subscribe to my blog, please enter your details below. You can unsubscribe at any time.