Skip to content

Instantly share code, notes, and snippets.

Last active Jun 30, 2022
What would you like to do?
import os
from PIL import Image
import getpass
import glob
import_file = os.path.join('C:/Users',getpass.getuser(),'入力ファイル名')
export_file = os.path.join('C:/Users',getpass.getuser(),'入力ファイル名')
RESIZE_X = 1280
RESIZE_Y = 720
isASPECT = True
def resize(image):
resize_x = RESIZE_X
resize_y = RESIZE_X / image.width * image.height if isASPECT == True else RESIZE_Y
return image.resize((int(resize_x),int(resize_y)))
files = glob.glob(os.path.join(import_file,'*.png'))
for file in files:
img =
img = resize(img)
basename = os.path.basename(file)
#指定のフォルダに画像を保存 , basename))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment