Python: Get Image Size

By Xah Lee. Date: .
# 2024-11-22
# get image size
# file name: get-img-size.py
# return a space separated string, of image width and height

# example
# python get-img-size.py mycat.jpg

import sys

from PIL import Image

imagepath = sys.argv[1]

ximage = Image.open(imagepath)
xwidth, xheight = ximage.size
print(xwidth, xheight)

Python, System Call Related

Get Image Width Height