특정 경로 밑 이미지를 사이즈 재조정후 일괄저장¶
In [21]:
import os
from PIL import Image
from tqdm import tqdm_notebook
import glob
In [22]:
def getResizedJPG(path, target_path) :
for infile in tqdm_notebook(glob.glob(path, recursive=True)):
basewidth = 250
img = Image.open(infile)
wpercent = (basewidth/float(img.size[0]))
hsize = int((float(img.size[1])*float(wpercent)))
img = img.resize((basewidth,hsize), Image.ANTIALIAS)
img.save(target_path + os.path.basename(infile))
In [ ]:
getResizedJPG("/test/**/*.jpg","d:/image/all/test/")