Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vladimirmyshkovski/c6ceeac1c441b13888fa2dfea60236b7 to your computer and use it in GitHub Desktop.
Save vladimirmyshkovski/c6ceeac1c441b13888fa2dfea60236b7 to your computer and use it in GitHub Desktop.
resize all images in folder PIL python
In [11]: #!/usr/bin/python
...: from PIL import Image
...: import os, sys
...:
...: path = "/var/www/gglobal/media/images/"
...: dirs = os.listdir( path )
...:
...: def resize():
...: for item in dirs:
...: if os.path.isfile(path+item):
...: im = Image.open(path+item)
...: f, e = os.path.splitext(path+item)
...: imResize = im.resize((200,100), Image.ANTIALIAS)
...: imResize.save(f, 'png', quality=80)
...:
...: resize()
@Tariqul2h2
Copy link

why its not working for me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment