the site of Leo Baker…

create lower resolution image proxies with python

For those who are friends of the command line, here is a simple python script that utilises PIL to generate lower resolution proxy images of your larger files.

This is often handy when doing any kind of vfx work where smaller files allow for faster interaction. The script is setup to process individual files or entire folders of images. I also use it a lot for quickly creating emailable size images from the larger res downloads off my digital camera. At the moment the script is setup merely to create jpeg type files, but I wanted to later implement the option of maintaining the original file format, or just specifying an output filetype.

Usage

From commandline:

python pathToLB_proxyMaker.py fileOrFolderToSourceFrom args

or of course, you can alias it to ‘proxy’ or whatever you like.

FLAGS:
-p      Sets the divisional ammount to create the new smaller res files. The images will be divided by this number.
-t      CURRENTLY NOT IMPLEMENTED: is intended to maintain the file format of the original files -otherwise will default to jpeg.
-w      Sets the target proxy Res so that the larger dimension is 640 – which is an ideal size for email and web work.
If images are smaller than this res they will not be alterred.
-1      Sets the target proxy Res so that the lerger dimension is 1024 – for a 1k approximation.
If images are smaller than this res they will not be alterred.

FLAGS:

-d –division Sets the divisional amount to create the new smaller res files. The images will be divided by this number.

-w –web Sets the target proxy Res so that the larger dimension is 640 – which is an ideal size for email and web work. If images are smaller than this res they will not be altered.

-1 –1k Sets the target proxy Res so that the larger dimension is 1024 – for a 1k approximation. If images are smaller than this res they will not be altered.

-t --type CURRENTLY NOT IMPLEMENTED: is intended to maintain the file format of the original files -otherwise will default to jpeg.

You can get it to make proxies based on a division amount of the original res -half res, quarter res etc. This is by using the “-d” flag followed by a dividing number. Eg. “-d 2″ will make half res files or “-d 4″ will make quarter res files. I have also included a couple of handy modes for making web or email size files.The flag “-1″ will make 1k files (where the larger of the 2 dimensions is set to 1024 pixels), or the flag “-w” makes a slightly smaller equivalent, where the larger of the 2 dimension is set to 640 pixels.

Known drawbacks

Unfortunately the version of PIL available at the time I wrote this post has a few annoying limitations. The main problem is that it will not maintain the image’s colour profile, or any other associated meta data. So if you have a particular colour profile assigned to your images, say ’sRGB’, it will not exist on the newly output proxy files. On my computer (Mac) I think it just assigns a ‘colour LCD’ profile upon opening the images -which can often look rather ordinary. Although you can manually reassign a colour profile to your images at a later date. I think there are various scripts out there that can do this, but that again is irritating as it means it becomes a 2 part process.  I believe the next version of PIL (1.1.7) should address maintaining the colour profile across image manipulation.

Reply

Spam Protection by WP-SpamFree