9951 explained code solutions for 126 technologies


python-pillowHow to get image size


from PIL import Image, ImageDraw, ImageFont

im = Image.open('/var/www/examples/heroine.png')
width = im.size[0]
height = im.size[1]ctrl + c
PIL

import Pillow package modules

Image.open

open given image with Pillow

/var/www/examples/heroine.png

path to sample image to open

im.size

returns original image width and height

im.size[0]

image width

im.size[1]

image height


Usage example

from PIL import Image, ImageDraw, ImageFont

im = Image.open('/var/www/examples/heroine.png')
width = im.size[0]
height = im.size[1]

print(width, height)
output
733 1100