Created
May 18, 2017 00:15
-
-
Save vladimirmyshkovski/c6ceeac1c441b13888fa2dfea60236b7 to your computer and use it in GitHub Desktop.
resize all images in folder PIL python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
why its not working for me?