Answers for "how to load images from folder in python"

1

python get all images in directory

import glob

for filename in glob.iglob(root_dir + '**/*.jpg', recursive=True):
    # Do something
Posted by: Guest on December-22-2020
0

how to load images from folder in python

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)))
Posted by: Guest on June-30-2021

Code answers related to "how to load images from folder in python"

Python Answers by Framework

Browse Popular Code Answers by Language