СС
try:
# PIL
import Image
except ImportError:
# Pillow
from PIL import Image
def process_image(img_path):
print ("Processing image: %s") % img_path
# Open the image
img = Image.open(img_path)
# Do your processing here
print (img.info)
# Not strictly necessary, but let's be explicit:
# Close the image
del img
images_dir = "E:\keras-tutorial\codes"
if name == "main":
# List all PNG files in your directory
images_list = glob(os.path.join(images_dir, "*.png"))
for img_filename in images_list:
img_path = os.path.join(images_dir, img_filename)
process_image(img_path)