Skip to content

Instantly share code, notes, and snippets.

@mtayseer
Created February 23, 2014 11:55
Show Gist options
  • Save mtayseer/9170422 to your computer and use it in GitHub Desktop.
Save mtayseer/9170422 to your computer and use it in GitHub Desktop.
Given a directory, compress all images in it
import sys, os
from PIL import Image
files = os.listdir(sys.argv[1])
for i, f in enumerate(files):
fname = os.path.join(sys.argv[1], f)
im = Image.open(fname).save(fname)
print 'Compressing {} of {}'.format(i, len(files))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment