Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

20 righe
647 B

  1. # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
  2. # MIT License. See license.txt
  3. from __future__ import unicode_literals, print_function
  4. import os
  5. def resize_images(path, maxdim=700):
  6. import Image
  7. size = (maxdim, maxdim)
  8. for basepath, folders, files in os.walk(path):
  9. for fname in files:
  10. extn = fname.rsplit(".", 1)[1]
  11. if extn in ("jpg", "jpeg", "png", "gif"):
  12. im = Image.open(os.path.join(basepath, fname))
  13. if im.size[0] > size[0] or im.size[1] > size[1]:
  14. im.thumbnail(size, Image.ANTIALIAS)
  15. im.save(os.path.join(basepath, fname))
  16. print("resized {0}".format(os.path.join(basepath, fname)))