正如标题所说,我正在寻找一种将大量图像转换为不同大小的缩略图的方法,我如何在 python 中执行此操作
最佳答案
参见: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
关于python - 使用 python 创建 jpeg 的缩略图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2612436/