Skip to content

Instantly share code, notes, and snippets.

@tamboer
Created September 1, 2013 19:31
Show Gist options
  • Select an option

  • Save tamboer/6406711 to your computer and use it in GitHub Desktop.

Select an option

Save tamboer/6406711 to your computer and use it in GitHub Desktop.
batch image resize - cli shell tasks
# apt-get install imagemagick
Once installed you will have multiple image processing tools available to our disposal, such as convert, identify and etc.
identify command will help you to get some image information and convert will help you to convert images between hundreds of different image formats as well as it will easily resize any image submitted as an argument.
Let's suppose that our current working directory contains multiple image files with extension *.jpg . To resize all images to a half size of their original size we can combine bash for loop and convert command together in a following manner:
Code:
$ for i in $( ls *.jpg); do convert -resize 50% $i re_$i; done
The command above will resize all images to half of its original size. New resized images will be saved with a prefix "re_". It is also possible to resize all images and at the same time convert them to gif format:
Code:
$ for i in $( ls *.jpg); do convert -resize 50% $i $i.gif; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment