pil slicing

a guest Oct 8th, 2011 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import os
  2. from PIL import Image
  3. imdir = "directory of images"
  4. savedir="path to where you wanna save the files"
  5. files = [os.path.join(imdir, fname) for fname in os.lsdir(imdir)]
  6. for infile in files:
  7.     im =
  8.     file, ext = os.path.splitext(infile)
  9.     //first region
  10.     slice1 = im.crop((left, upper, right, lower)
  11."slice1", "JPEG")
  12.    //copy and paste with new boxes
RAW Paste Data
Want to get better at Python?
Learn to code Python in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!