Advertisement
Guest User

pil slicing

a guest
Oct 8th, 2011
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  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 = pil.Image.open(infile)
  8.     file, ext = os.path.splitext(infile)
  9.     //first region
  10.     slice1 = im.crop((left, upper, right, lower)
  11.     slice.save(file+"slice1", "JPEG")
  12.    //copy and paste with new boxes
  13.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement