Linux – Resize a directory of pictures

In Linux, resizing a large amount of pictures is very simple. This is a neat little command line script perfect for making thumbnails to go on websites or what not, and I’ve used it in some PHP websites before.

for i in *.jpg; do convert -resize 640x480! -quality 75 "$i" thumb/"$i"; done

The script shouldn’t be too difficult to understand. It loops through every file in the directory ending with a .jpg extension. Change this as required. It than runs the convert program, part of the ImageMagick program which should be available via your distribution’s package manager. It resizes it to the dimensions specified (width x height in pixels). The thumbnails will have 75% quality (To reduce size), and be stored in the thumb sub directory of the current directory.

Leave a Reply