Canon Image Resizer Script v .5 – smallver.py

by Piotr Krzyzek on March 16, 2009

Canon DSLR camera’s can produce amazing photographs, though the problem arises in holding those files. Even a bigger problem to e-mail it. A `simple’ image from a 40D in best quality will easily produce an image of 5MB. Not exactly e-mail worthy, nor website worthy for displaying. Sure, it’s great if you want people to see it in best quality AND wait forever to actually see it.

So, being a user of a 40D I needed a way to quickly resize (scale down) all the pictures, in a command line way. I also needed plenty of other features which I really did not feel like manually typing all the time. Thus out came my smallver.py script (smallver dot Py).Currently still in beta and in version .5. Also it’s made for linux and in python 2.5. Though I’m pretty sure it’ll work in py 2.4.

This script is in essence a wrapper for Imagemagick (which is requied for use). IM had a lot things that bothered me, so I wrapped all of it in a easy script. Here is what my script will currently do (more or less in order):

  • Find all .jpg and .jpeg files in a given folder
    • ignoring all not supported files (will add quick raw support soon)
  • Create a ‘small_ver’ folder to place all the scaled down files into
  • Current scaling is down to 1200×800
  • Create all scaled down images in ‘small_ver’ folder

It has several useful features, here is a mostly complete list of current features:

  • Image scaling using ImageMagick
  • Image filtering (selecting only image files)
  • Multiple file and folder input
  • Command line version for quick and easy access
  • Selecting your own ‘small’ version tag
  • Overwrite and non-overwrite ‘small_ver’ modes
  • Small version folder selection
  • (Poor) non-standard file dimension handling
  • and more …

I have also left the comments in in this release. Hopefully they will be useful to others should they choose to look at the code.

Download: smallvery.py

Usage of the program is rather simple. Simply call smallver.py with a image or folder as an argument.

$ smallver.py /home/pictures/picture_folder_to_resize

This will create a small_ver folder in your current working directory and place all scaled images there. If you want your pictures in the subdictory of the original folder you can do one of two things:

  • $ smallver.py -d /home/pictures/directory/small_version_folder /home/pictures/directory
  • cd picture_directory; /home/programming/smallver.py ./

Where ‘/home/programming/’ is the path to the smallver.py scipt.

The –help option displays all currently possible functions.

$ ~/Programming/python/smallver.py –help
Usage: smallver.py [options] FILE|DIRECTORY

Script for shrinking Canon sized image files to a more useable size. Default
size is 1200×800.

Options:
-h, –help                Show this help message and exit
-v, –verbose           Be verbose
-w, –debug            Debug messages
-o, –overwrite       Overwrite files and folders if they exist
-s SIZE, –size=SIZE  Size Selection for the image
-d DIRECTORY, –folder=DIRECTORY Directory where the small versions will be
-t TAG, –tag=TAG     Small file version tag

Multiple file input support:

$ smallver.py image1.jpg image2.jpg

Even file and directory support:

$ smallver.py image1.jpg some_folder/ other_image.jpg

I hope this script can be of use to all of you. Good luck.

Download: smallvery.py

Related posts:

  1. Canon 40D Firmware 1.1.1 Update
  2. Photography with Canon 30D …
  3. IMBorder.py – ImageMagick with Python automagic photograph borders (version .1.5)
  4. First HDR Test image
  5. YouTube : Blue Mind – Hana Yori Dango piano – Youtube Script Test.

Leave a Comment

CommentLuv Enabled

Previous post:

Next post: