skip to main content
Avatar of Nicklas Jarnesjö
Nicklas Jarnesjö

Resize images through unix terminal


This is a small script I use to resize and shrink size of images through unix terminal.

for file in *.jpg; do convert $file -strip -resize 2660x\> -quality 80 "`basename $file .jpg`-resized.jpg"; done

The script will resize all jpg images in the folder to a max-width of 2660px and a quality of 80 and also remove all metadata from the image. Simple to modify to your needs. This will also keep the original images.

If you want to override the original images you can use the following script.

for file in *.jpg; do convert $file -strip -resize 2660x\> -quality 80 "$file"; done

For this to work you need to have imagemagick installed on your system. imagemagick on Homebrew

brew install imagemagick
Discuss this post on Twitter