import os
import sys
import string
import math
from os import getcwd
from PIL import Image
Fix_X = 400
Fix_Y = 400
def ProcessFile(aFile):
mTuple = os.path.split(aFile)
curdir = mTuple[0];
fileName = mTuple[1];
extendName = fileName.split('.').pop()
if extendName == "gif" or extendName == "bmp" or extendName == "jpg" :
im = Image.open(aFile)
xsize, ysize = im.size
#print xsize,ysize
V_SPLITE = int(math.ceil((xsize * 1.00)/(Fix_X * 1.00)))
H_SPLITE = int(math.ceil((ysize * 1.00)/(Fix_Y * 1.00)))
#print V_SPLITE,H_SPLITE
for i in range (0, H_SPLITE ):
for j in range ( 0 , V_SPLITE ):
pointX=j*Fix_X
pointY=i*Fix_Y
if (pointX+Fix_X)>xsize :
width=xsize-pointX
else:
width=Fix_X
if (pointY+Fix_Y)>ysize:
height=ysize-pointY
else:
height=Fix_Y
im_temp = Image.new('RGB',(width,height))
box = (pointX,pointY
,pointX+width,pointY+height)
#print box
region = im.crop(box)
im_temp.paste(region,(0,0))
im_temp.save(curdir+"_"+"%s"%(V_SPLITE*i + j) + ".jpg")
def TraverseDir(aPath):
mList = os.listdir(aPath)
for mPath in mList: