SHARE
TWEET

pil slicing

a guest Oct 8th, 2011 74 Never
  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.  
RAW Paste Data
Top