Archive
Posts Tagged ‘content-length’
Get the size (dimension) of an image
April 4, 2011
Leave a comment
Problem
You want to get the size (dimension) of an image.
Solution
We will use the Pillow package here, which is the successor of PIL.
from PIL import Image # uses pillow image_file = "something.jpg" im = Image.open(image_file) print im.size # return value is a tuple, ex.: (1200, 800)
Related
If the image is on the web and you don’t want to download it, you can get the size of the image in bytes (see this post and get ‘Content-Length’).
Categories: python
content-length, image dimension, image size
