Time Lapse Batch Image Manipulation Using Python

by MakersBox in Craft > Digital Graphics

7410 Views, 7 Favorites, 0 Comments

Time Lapse Batch Image Manipulation Using Python

brightened.jpg
I recently found a cool Time Lapse app for my phone, but the files needed to be rotated and touched up a bit to make them into a movie. I wrote a Python script to do that, and am sharing that with you here.

Gather Images

original.jpg
rotated.jpg
brightened.jpg
I'm using an app called Time Lapse Camera (http://www.thirdwishsoftware.com/timelapsemaker/) on a Palm Pre. It places sequentially numbered photos in a directory. I'm sure what ever phone you use, "there is an app for that." You could use a webcam as well.

The problem, as you can see below, is that the images need to be rotated and touched up a bit. There are many ways to do this including Gimp and ImageMagick, but for me a Python script was the easiest and quickest.  Python is available at http://www.python.org/getit/. I am also using the Python Image LIbrary (PIL), available at http://www.pythonware.com/products/pil/.

Batch Processing

command_line.jpg
idle.jpg
Place the script in a folder with or below the folder containing the images to be processes.

The script can be run from the command line with the desired options.
In this example, the script is located in:
     C:\Users\Ken\Pictures
And the images in:
     C\Users\Ken\Pictures\commute

The command to rotate and brighten images in the folder is:
    python ./imageBatch.py -d commute -r 90 -b 1.5

Or, if you would rather, open, modify it, and run it from Python's own command line tool, Idle.

Just a side note, I had to add python to my path to get the command line option to work in windows.

Here are the command line options if you enter "imageBatch.py -h":

       -h --help : displays this help message
       -d --directory : directory, relative to this file, where the photos are located (omit if in same directory)
       -e --equalize : equalize image contrast
       -r --rotation : degrees to rotate (+ = ccw, - = cw)
       -c --contrast : contrast factor (1.0 = unchanged)
       -b --brightness : brightness factor (1.0 = unchanged)
       -s --sharpness : sharpness factor (1.0 = unchanged)
       -t --timestamp : add file created time to images

You are not stuck with just these options. Visit http://www.pythonware.com/library/pil/handbook/ to learn what is available in the library and modify the script to do what you want. I've merely given you a frame work to put options in to.

Downloads

Make the Movie

movemaker.jpg
Once you have the images the way you want, time to make a movie. I used Movie Maker Live. You can import the entire folder of images at once and set their duration to something low like 0.2 seconds.

That is it. Good luck.