- 0
- 이니스프리
- 조회 수 574
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | from PIL import Image import os, glob def check_remove( file ): im = Image. open ( file ) w, h = im.size # width, height를 각각 반환합니다. im.close() # Pillow에서 파일을 닫아줍니다. if h < 100 : print ( file ) os.remove( file ) dir = '경로를 입력하세요' files = glob.glob( dir + '\\*.*' ) for f in files: check_remove(f) |
im.close()를 하지 않으면 Pillow에서 해당 파일을 오픈한 상태이기 때문에 os.remove할 수 없어요 ㅠㅠ
더 효율적이고 빠른 방법이 있을 것 같은데 좀 더 고민해볼게요~ ^^
님 포함 1명이 추천
추천인 1
작성자
댓글 0
권한이 없습니다.