Created
October 18, 2022 09:05
-
-
Save arth2o/e79dca65372e825876c4e09db2540d67 to your computer and use it in GitHub Desktop.
Resize .jpg in a folder keep aspect ratio. New image name will be extend with _t tag.
This file contains 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
#!/usr/bin/python | |
# install | |
# pip install super-image | |
from PIL import Image | |
import os, sys, glob | |
path = "./" | |
dirs = os.listdir( path ) | |
def resize(): | |
path = "./" | |
dirs = glob.glob(path+'*.jpg') | |
for item in dirs: | |
im = Image.open(path+item) | |
f, e = os.path.splitext(path+item) | |
# keep image aspect ratio | |
im.thumbnail((2000,2000)) | |
print(f); | |
im.save(f + '_t.jpg', 'JPEG', quality=72) | |
resize() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment