Posts

Showing posts from January, 2009

Resize image before uploading

Where Internet connection is slow, it takes too much time to upload images. Few days ago I was trying to upload some images in facebook and it seemed to take forever. The I wrote the following python program to reduce the image size (around 4MB to around 100 KB!): import Image import os, sys # adjust width and height to your needs width = 800 height = 600 for root, dirs, files in os.walk('./'): for name in files: filename = os.path.join(root, name) if filename.endswith('jpg'): print filename imin = Image.open(filename) imout = imin.resize((width, height), Image.BICUBIC) imout.save(filename)