Binary files: Images


This is just a quick example how to use the Pillow module to handle images. There is a whole chapter on dealing with images.

examples/pil/get_image_size.py
from PIL import Image
import sys

if len(sys.argv) !=2:
    exit(f"Usage: {sys.argv[0]} FILENAME")

in_file = sys.argv[1]

img = Image.open(in_file)
print(img.size)    # a tuple
print(img.size[0]) # width
print(img.size[1]) # height