Python obtient toutes les images dans le répertoire
import glob
for filename in glob.iglob(root_dir + '**/*.jpg', recursive=True):
# Do something
CBT fan club
import glob
for filename in glob.iglob(root_dir + '**/*.jpg', recursive=True):
# Do something
from PIL import Image
import glob
image_list = []
for filename in glob.glob('yourpath/*.gif'): #assuming gif
im=Image.open(filename)
image_list.append(im)
from PIL import Image
import os, os.path
imgs = []
path = "/home/tony/pictures"
valid_images = [".jpg",".gif",".png",".tga"]
for f in os.listdir(path):
ext = os.path.splitext(f)[1]
if ext.lower() not in valid_images:
continue
imgs.append(Image.open(os.path.join(path,f)))