Bulk image resize script in Python

This is a simple python script I wrote for mass resizing large collections of digital images. Its one of my first python scripts, but does a lot of good work. I can just tell the script which folder contains all the images, then sit back and relax while the processing goes on.

Why resize my Images ?
Most of the images from your digital cam will be around 3MB. Their dimensions will be approximately 3000x2000 pixels. Now that is waaay bigger than the size of your monitor!
Even if you have a 21" monitor, your image needs only a size of 1600x1200 pixels for best view. Of course, if you have some special images out there, bigger dimensions enable more zooming and cropping-the-favorite-part and stuff.
Still you'll find that majority of the images are not worth their huge sizes. If you have a 15" monitor and you resize an image to 1024x768 pixels, you'll not even feel any difference in the quality. But then its size on disk will reduce from 3MB to atmost 500KB - that's only 20% of the original size! Doing a little math, if you have 5GB of images, it will all reduce to a simple 1GB with no perceivable loss in image quality!
And that's what this script is all about.

Working how to

This script now works in linux platform. You can install it run it from the terminal.

Here's a screenshot of the process: (click to enlarge)

The script displays the progress, currently processed folder and file etc. Note that this is intended for large scale image processing. But I won't mind if you use it for processing small amount of data. Actually you can use it beautifully for generating thumbnails and so.

Download script

Download source (in case you want to dig into it)

Refer the read me file in the downloaded archive to install.
After install browse to the required folder and type imageresize --start and the scaling process simply starts!
The script comes with a few custom options. Too see them type imageresize --help
Caution: The script replaces the original image with the resized image. So take care to move your special images before you call the script. Also, note that all the images in the sub-folders are also scaled down.

You need Python imaging libraries installed for this to work. If the program exits with such an error, you should install these modules first. Get it here.

Alternative way
The program can work also with Imagemagick, an awesome command line image processing tool. This results in slower image processing. The output images are bigger in size than the above script, but its quality is slightly better.
(In Ubuntu, install the program as sudo apt-get install imagemagick )
Get Imagemagick here, and the corresponding script below:

Download script

Download source (in case you want to dig into it)

Enjoy the free space in your hard disk!


  1. Great script, functional and instructive source for a python beginner as well.

  2. I spoke too soon! I can't get the options syntax to work in the ImageMagick version.

    imageresize -o '640' --start

    That command makes every file 1024px wide. Is the syntax wrong? Thanks

  3. thank you, I remember that my best friend fixed my computer yesterday, I think that this kind of things in the computers is something so complicated!