Image
from slint import ImageImage objects can be set on Slint Image elements for display. Construct Image objects from a path to an
image file on disk, using load_from_path.
Properties
Section titled “Properties”The size of the image as a tuple of width and height.
width: intThe width of the image in pixels.
height
Section titled “height”height: intThe height of the image in pixels.
path: pathlib.Path | NoneThe path of the image if it was loaded from disk, or None.
Methods
Section titled “Methods”load_from_path
Section titled “load_from_path”Loads the image from the specified path. Raises RuntimeError if the image can’t be loaded.
load_from_svg_data
Section titled “load_from_svg_data”Creates a new image from bytes that describe the image in SVG format.
load_from_array
Section titled “load_from_array”Creates a new image from an array-like object that implements the Buffer Protocol ↗. Use this function to import images created by third-party modules such as matplotlib or Pillow.
The array must satisfy certain constraints to represent an image:
- The buffer’s format needs to be
B(unsigned char) - The shape must be a tuple of (height, width, bytes-per-pixel)
- If a stride is defined, the row stride must be equal to width * bytes-per-pixel, and the column stride must equal the bytes-per-pixel.
- A value of 3 for bytes-per-pixel is interpreted as an RGB image, a value of 4 means RGBA.
The image is created by performing a deep copy of the array’s data. Subsequent changes to the buffer aren’t reflected in a previously created Image.
Example of importing a Matplotlib figure into an image:
import slintimport matplotlib
from matplotlib.backends.backend_agg import FigureCanvasAggfrom matplotlib.figure import Figure
fig = Figure(figsize=(5, 4), dpi=100)canvas = FigureCanvasAgg(fig)ax = fig.add_subplot()ax.plot([1, 2, 3])canvas.draw()
buffer = canvas.buffer_rgba()img = slint.Image.load_from_array(buffer)Example of loading an image with Pillow:
import slintfrom PIL import Imageimport numpy as np
pil_img = Image.open("hello.jpeg")array = np.array(pil_img)img = slint.Image.load_from_array(array)© 2026 SixtyFPS GmbH