resize multiple images using shell

Good news for linux users, bulk resizing pictures is extremely easy thanks to imagemagick.

Here are the steps to follow:

  1. install imagemagick – for debian/ubuntu:
    sudo apt-get install imagemagick
  2. go to your folder:
    cd <path_to_my_folder>
  3. reisze your pictures:
    for file in *.jpg; do convert $file -resize 1024x1024 -quality 90 resized_$file; done
  4. that’s it! once process is finished, you will see all resized files:
    ls resized_*.jpg

This is very useful to minimize space used on cloud storage (ex: picasa, googledrive, …), speed up upload of pictures and number of pictures that can be stored!

Even better:

  • imagemagick keeps ratio when resizing by default, which is really good => “-resize 1024×1024” means your file will keep ratios and havee at max 1024 on one side, which is precisely what I want
  • forcing imagesize: if you want to force new size and ignore existing ratio, simply append a ‘!’ => “-resize 1024×1024!” => this time all your pictures will be 1024×1024
  • rotation: convert pict.jpg -rotate 90 pict-rotated.jpg
  • convert from one format into another: convert pict.png -quality 95 pict.jpg
  • update existing image: easy simply use same name for both input and output
  • apply effects (ex: charcoal, implode, …): convert pict.jpg -implode 1 pict-imploded.jpg

You can of course combine all the effects in a single command and create a batch using above mentioned syntax:

for file in *.png; do convert $file -resize 1024×1024 -rotate 180 -charcoal 4 -quality 95 modified-$file; done

This is simply an overview of the many many many features that imagemagick has to offer.

For more information:

man convert


Post a Comment

Your email is never published nor shared. You're allow to say what you want...