Skip to content

Instantly share code, notes, and snippets.

@stucka
Created April 7, 2017 18:40
Show Gist options
  • Save stucka/6c32d21bc0ab5e32b1d1056b7193b449 to your computer and use it in GitHub Desktop.
Save stucka/6c32d21bc0ab5e32b1d1056b7193b449 to your computer and use it in GitHub Desktop.
Get list of image dimensions from a folder
from PIL import Image
import os
folder = "./static/imgoriginals/"
print("Width\tHeight\tFilename")
for lead in os.listdir(folder):
filename = os.path.join(folder, lead)
im = Image.open(filename)
width, height = im.size
try:
im = Image.open(filename)
width, height = im.size
print(str(width) + "\t" + str(height) + "\t" + filename)
except:
print("!\t!\t" + filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment