랭귀지/python

이미지 파일 확인하기

유키공 2018. 6. 7. 09:30

Python 이미지 파일 확인하기

이미지 파일들의 집합을 빠르게 확인하는 단순한 스크립트입니다.
 
import os, sys
import Image
 
size = 128, 128
 
for infile in sys.argv[1:]:
    outfile = os.path.splitext(infile)[0] + ".thumbnail"
    if infile != outfile:
        try:
            im = Image.open(infile)
            im.thumbnail(size)
            im.save(outfile, "JPEG")
        except IOError:
            print "cannot create thumbnail for", infile