from PIL import Image from PIL import ImageOps import time i = 1 while True: page = Image.open("bounding_box/input%i.jpg"%i) if i % 2 == 0: #check where the for loop is print("cropping even") # left, up, right, bottom border = (0, 0, 165, 0) finalpage = ImageOps.crop(page, border) finalpage.save('cropped/page%i.jpg'%i) else: #check where the for loop is print("cropping odd") # left, up, right, bottom border = (165, 0, 0, 0) finalpage = ImageOps.crop(page, border) finalpage.save('cropped/page%i.jpg'%i) time.sleep(1) print("variable i: ", i) i+=1