Last active
August 9, 2016 14:40
-
-
Save squamous/bee9d1d50b4d51311c6af0abe58bba59 to your computer and use it in GitHub Desktop.
Revisions
-
squamous revised this gist
Aug 9, 2016 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,18 +6,18 @@ from PIL import Image if __name__ == '__main__': if len(sys.argv) > 2: percentage = int(sys.argv[1]) / float(100) print 'Resizing each image by %s%%' % (percentage * 100) imgs = sys.argv[2:] for fname in imgs: img = Image.open(fname) w, h = img.size img = img.resize( (int(w * percentage), int(h * percentage)), Image.BILINEAR ) img.save("resize_%s" % fname) else: print '%s <percentage> [file ...]' % os.path.basename(sys.argv[0]) -
squamous revised this gist
Aug 9, 2016 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,8 @@ # # Resize a set of images by a given percentage. import sys, os from PIL import Image def perc(num, perc): -
squamous created this gist
Jul 29, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ #!/usr/bin/env python # # Resize a set of images by a given percentage. import sys, os, Image def perc(num, perc): return (float(perc) / 100) * float(num) if __name__ == '__main__': if len(sys.argv) > 2: percentage = sys.argv[1] print 'Resizing each image by %s%%' % percentage imgs = sys.argv[2:] for fname in imgs: img = Image.open(fname) w, h = img.size img = img.resize((perc(w, percentage), perc(h, percentage)), Image.BILINEAR) img.save("resize_%s" % fname) else: print '%s <percentage> [file ...]' % os.path.basename(sys.argv[0])