Load an image file and populate image metadata (width, height, format).
load_image(filename)
filename - Path to the image file to load (PNG, JPEG, or GIF)A binary value containing the image data with populated metadata:
width - Image width in pixelsheight - Image height in pixelsformat - Image format ("png", "jpeg", or "gif")content_type - MIME type ("image/png", "image/jpeg", or "image/gif")filename - Original filenameLoads an image file and automatically decodes it to extract width and height information. The metadata is immediately available on the returned binary value.
This is a convenience wrapper around load_binary() that adds image metadata extraction.
Same as load(). See Files, Modules, and Paths for the full table of path roots.
Supports PNG, JPEG, and GIF formats. The format is automatically detected and populated in metadata.
img = load_image("photo.png")
print("Size:", img.width, "x", img.height)
print("Format:", img.format)
img = load_image("original.jpg")
scaled = scale_image(img, 800, 600, "fit")
save_image(scaled, "scaled.jpg")
img = load_image("landscape.png")
cropped = crop_image(img, 100, 100, 400, 400)
save_image(cropped, "cropped.png")