5
创建JPEG文件的缩略图正如标题所说我正在寻找一种方式将图像转换的一个庞大的数字为不同大小的缩略图,我怎么去在Python与蟒蛇
创建JPEG文件的缩略图正如标题所说我正在寻找一种方式将图像转换的一个庞大的数字为不同大小的缩略图,我怎么去在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
如果你需要它是一个正方形的缩略图不管原始图像的宽高比,然后看看http://stackoverflow.com/questions/1386352/pil-thumbnail-and-end-up-with-a-square -图片。 – Seth 2014-03-13 16:41:17