Python Image Processing and PIL

I wrote the following code (based on code provided in the PIL documentation) to halve the size of all jpeg images in a folder and save as a new file. Not the fastest code, but it worked pretty well.

from PIL import Image

import glob, os

newPath = raw_input("folder to process:")
for infile in glob.glob("*.jpg"):
file, ext = os.path.splitext(infile)
im =
print file
x = int(im.size[0]*0.5)
y = int(im.size[1]*0.5)
size = x,y
im.resize(size, Image.ANTIALIAS) + "_small_" + ".jpg")

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

A Website.

Up ↑

%d bloggers like this: