Mass resize images (.jpg/.png/etc) in folder


  • imagemagick package installed

Generally, the command for a single file is:

convert [input_image.jpg] -resize [percentage]% [output_image.jpg]

Now, to batch-resize a folder with images we can write a small shell script that converts each image in the folder.

We want the resized images in a subfolder called “resized”.

if [ ! -d resized ]; then
   mkdir resized

for f in `find . -name "*.JPG"`
    convert $f -resize 50% resized/$f

In the example above, we find all files with “.JPG” extension and pass them to the convert command.

Also, see the “-resize 50%” part. You might want to adjust 50 to your needs.

Drop that script into the folder, e.g. ~/images/ and:

cd ~/images/
chmod u+x

Leave a Reply