Bildbearbeitung mit Pillow
Thumb’s erstellen
from PIL import Image
import glob, os, sys
size = 128, 128
folder = os.path.dirname(__file__)
os.chdir(folder)
print(os.getcwd())
# l = [f for f in os.listdir(folder) if f.endswith('.jpg')]
for infile in os.listdir(folder):
try:
im = Image.open(infile)
file, ext = os.path.splitext(infile)
print(infile)
im.thumbnail(size, Image.ANTIALIAS)
im.save(file + "-thumb.jpg", "JPEG")
except:
print("Unexpected error: " , sys.exc_info()[0])