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