Jumprit's Knowledge

Jumprit's knowledge and references to share.

Batch Resize in Terminal (Linux) —

Use Imagemagick to resize images in terminal (using mogrify command).

To make life easier, just copy this script and run from your images directory.


function resize {

	mogrify -quality 75 -resize 960 ${1}
	h=$(identify -format %h ${1})
	if [ $h -gt 640 ]; then
		mogrify -quality 100 -shave 0x$cut ${1}

for i in `ls -1 *.JPG *.jpg`; do
	resize ${i}

Run it inside a folder with jpg files and it will resize all the files
(it will overwrite the originals).
Play with the sizes to fit your needs (max width is 960 and max height is 640).
And you can also adjust quality.

Categorised as: Linux

Leave a Reply