Friday, October 05, 2007

Bulk resize with python

Recently I had to pick up python for a project. So as usual, it is easier and more fun for me to learn something if there is a purpose! So this time, since I'd been messing around with a new camera, I wanted to have something to bulk resize my pics. So I decided to write a script for it. And so here it is!
import Image, os

def make_smaller(path):
for item in os.listdir(path):
image =
image.thumbnail((583,389), Image.ANTIALIAS)
print 'Resizing: '+item'small/'+item)
except IOError: None

make_smaller('/home/widdlepuke/Desktop/Python module installers/test')

Very simple, and I must say, I do kinda like python now. I still like my perl though :p I am also currently messing with the Django framework. More on that next time.

No comments: