You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
689 B
Python

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