How to resize a batch of images on Linux?

Resizing images on Linux with gThumb is easy. However, I have a batch of images inside a folder. Manually resizing them will consume too much time.

How to automatically resize them on Linux with a script?

asked Nov 25, 2014 by Eric Z Ma (44,280 points)

1 Answer

Best answer

You can use convert from ImageMagick together with bash script to resize images inside a directory.

mkdir resize; \
IFS=$(echo -en "\n\b"); \
for i in *; do \
    echo $i; convert $i -resize 600^ resize/$i; \

The script will make a new directory named "resize" in current directory, resize all images in current directory to smaller ones of width 600px, and store the resized images into "reisze".

The line IFS=$(echo -en "\n\b") is a bash trick to handle situations where images file names have spaces.

answered Nov 25, 2014 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost