Imageio

2.37.3 · active · verified Sat Mar 28

Imageio is a mature Python library (current version 2.37.3) that makes it easy to read and write image and video data. This includes animated images, video, volumetric data, and scientific formats. It is cross-platform, runs on Python 3.10+, and is easy to install. The library is actively maintained with a focus on ease of use and broad format support.

Warnings

Install

Imports

Quickstart

This example demonstrates how to read an image using a built-in sample URI, convert it to grayscale using NumPy, and save the modified image to a new file. It utilizes the recommended `imageio.v3` API.

import imageio.v3 as iio
import numpy as np

# Read a standard image from imageio's sample data
im = iio.imread('imageio:chelsea.png')
print(f"Read image with shape: {im.shape}, dtype: {im.dtype}")

# Modify the image (e.g., convert to grayscale)
grayscale_im = np.dot(im[...,:3], [0.2989, 0.5870, 0.1140]).astype(np.uint8)
print(f"Grayscale image shape: {grayscale_im.shape}, dtype: {grayscale_im.dtype}")

# Write the modified image to a file
iio.imwrite('chelsea_grayscale.png', grayscale_im)
print("Saved 'chelsea_grayscale.png'")

# Clean up the created file (optional)
import os
# os.remove('chelsea_grayscale.png')

view raw JSON →