Skip to content

Instantly share code, notes, and snippets.

@leonsas
Last active August 29, 2015 14:19
Show Gist options
  • Save leonsas/5c29718213011fd2b485 to your computer and use it in GitHub Desktop.
Save leonsas/5c29718213011fd2b485 to your computer and use it in GitHub Desktop.
Cropping Pictures in Dir
from PIL import Image
import glob
filenames = glob.glob('*.png')
for f in filenames:
img = Image.open(open(f))
(w,h) = img.size
cropped_image = img.crop((0,0,w,w))
cropped_image.save(open('cropped_'+f,'w'), 'PNG')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment