RC1*_*140 5 python image-processing
正如标题所说,我正在寻找一种方法将大量图像转换为不同大小的缩略图,我如何在python中执行此操作
Kev*_*tre 17
请参阅:http://www.pythonware.com/products/pil/index.htm
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
Run Code Online (Sandbox Code Playgroud)