Last active
February 29, 2024 22:57
-
-
Save DLohn/3d613976e2d19940f6473045fa3900b0 to your computer and use it in GitHub Desktop.
Revisions
-
DLohn revised this gist
Feb 29, 2024 . 1 changed file with 1 addition 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 @@ -18,5 +18,5 @@ else: new_size = (int(resize_to * (im.width/im.height)), resize_to) im_resized = im.resize(new_size) im_resized.save(full_path) -
DLohn created this gist
Oct 25, 2023 .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 @@ import sys import os from PIL import Image resize_to = 384 target_dir = sys.argv[1] for file in os.listdir(target_dir): full_path = os.path.join(target_dir, file) try: im = Image.open(full_path) except: continue if im.width > im.height: new_size = (resize_to, int(resize_to * (im.height/im.width))) else: new_size = (int(resize_to * (im.width/im.height)), resize_to) im_resized = im.resize((resize_to, resize_to)) im_resized.save(full_path)