2010-04-10 10 views

Odpowiedz

15

Patrz: 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 
+0

Jeśli chcesz, aby była to kwadratowa miniatura niezależnie od proporcji oryginalnego obrazu, zobacz http://stackoverflow.com/questions/1386352/pil-thumbnail-and-end-up-with-a-square -obraz. – Seth