본문 바로가기

python/Pillow

여러장 이미지 일괄 크기조정

import os
import glob
from PIL import Image

files = glob.glob('C:\WearPerfume\*.jpg')

for f in files:
    img = Image.open(f)
    img_resize = img.resize((int(img.width / 2), int(img.height / 2)))
    title, ext = os.path.splitext(f)
    img_resize.save(title + '_half' + ext)

원본 폴더에 생성됩니다.

 

'python > Pillow' 카테고리의 다른 글

관리자 모드와 명령 프롬프트  (0) 2025.02.16
ImageDraw  (0) 2025.02.13
Image 생성  (0) 2025.02.12
이미지 속성  (0) 2021.03.06
여러장 사진 크기 제어 _resize  (0) 2021.03.05