1import glob
2
3for filename in glob.iglob(root_dir + '**/*.jpg', recursive=True):
4 # Do something
1from PIL import Image
2import os, os.path
3
4imgs = []
5path = "/home/tony/pictures"
6valid_images = [".jpg",".gif",".png",".tga"]
7for f in os.listdir(path):
8 ext = os.path.splitext(f)[1]
9 if ext.lower() not in valid_images:
10 continue
11 imgs.append(Image.open(os.path.join(path,f)))