Resize Multiple images in a folder (Batch Image Resize) in Ubuntu

You can resize multiple image files (jpg/png/gif….) stored in a folder by the imagemagick package. Here is step-by-step guideline:

Install ImageMagick

1. Install imagemagick from Ubuntu Software Center

Or, in the terminal:

sudo apt-get install imagemagick

Copy all of your images to a folder

2. Put all your image files in a single directory.

And don’t forget to take backup of your photos in a separate location.

3. Open a terminal and go to this directory:

cd <directory-location>

4. Now, enter following command to resize all of the images to a specific percentage. For examples, for the following command, all of the images will be reduced to 50% of their dimension maintaining the ratio.

mogrify -resize 50% -format jpg *

Where -format jpg specifies: the resultant format will be JPG.

Specify exact width & height

You may also specify width and height by the following command:

mogrify -resize 800x600 -format jpg *

You can easily guess, the resultant images will be of width 800 px and height of 600 px, keeping the original ratio.

Just mention width

Just mention width and the height will be automatically calculated, maintaining aspect ratio:

mogrify -resize 800x -format jpg *

That is, we told imagemagick that we want the images to be 800 pixels width. Height will be calculated automatically.


Full documentation here

29 thoughts on “Resize Multiple images in a folder (Batch Image Resize) in Ubuntu

  1. Hi….thanks for this good information.I’m so happy because it’s very useful for my thesis research.I hope you will keep updating your content constantly as you have one dedicated reader here🙂

  2. This is exactly what I needed to get some files ready to share on my blog and facebook. I shoot in RAW so I also needed to install ufraw and ufraw-batch packages to get this to work. Being able to resize my RAW files and convert them to jpg from the command line is wonderful! Thanks so much🙂

  3. Hi Thank you so much for sharing such a useful post.

    Would you please help me with one small question, Currently the resized image also is created in the same folder, would you please share the comment to create the resized image in a new folder so that I wont have it mixed up..

    1. As of IM v6.2.0 you can also use a new “-path” option to specify a different directory in which to output the processed images. This make it safer, however it will still overwrite any images of the same name that may already be in that directory.

  4. From the documentation:
    “The “mogrify” command is in many ways like “convert” except it is designed to modify images in place. That is it’s primary purpose is to read images (or animations), one file at a time, and modify them, before saving the image back into the exact same filename the image was read from. Because of this…
    Mogrify is dangerous, as it can easily destroy the original image!
    As such, before you do anything final, test “mogrify” with a separate copy of your images. Do not do use it on an original image that has no backup.”

  5. This was great to convert hundreds of pictures taken from a 12 Megapixel camera to 1920×1080 format for quick viewing on our Full HD TV (without having to wait for the TV to resize pictures one by one). Thank you very much!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s