Created
May 18, 2021 06:07
-
-
Save wendeehsu/74bc0bd0202a21086aa046885ebd37a3 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
from PIL import Image | |
import PIL | |
import os | |
foldernum = 0 | |
dir_name = "./HOPE圖庫" | |
for folder in os.listdir(dir_name): | |
if folder[-1] != 'g': | |
for file in os.listdir(dir_name+"/"+folder): | |
if file[-1] == 'g': // only handle jpg/png files | |
print(folder+"/"+file) | |
img = Image.open(dir_name+"/"+folder + "/" + file) | |
if img.size[0]*img.size[1] > 1000000: | |
img.save(dir_name+"/"+folder + "/" + file,optimize=True,quality=30) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment