Created
April 9, 2022 08:59
-
-
Save syanyong/c2aae15af4249a81b8775bbe575d3418 to your computer and use it in GitHub Desktop.
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
### Usage: python resize.py <directory of image> | |
### Example: python resize.py ~/Desktop/MyImages/ | |
import os, sys | |
from PIL import Image | |
import glob | |
# Resize size (will maintain the aspect ratio) | |
size = 224, 224 | |
i = 0 | |
for dirname in sys.argv[1:]: | |
files = glob.glob(str(dirname)+"*.jpeg") | |
for infile in files: | |
new_name = os.path.dirname(infile)+"/%d.jpeg" % i | |
print(infile, new_name) | |
os.rename(infile, new_name) | |
i = i + 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment