Image
from slint import Imagepython
Image 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”width: intheight
Section titled “height”height: intMethods
Section titled “Methods”load_from_path
Section titled “load_from_path”Loads the image from the specified path. Returns None if the image can’t be loaded.
load_from_svg_data
Section titled “load_from_svg_data”Creates a new image from a string that describes 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 RGB image, a value of 4 means RGBA.
Example of importing a matplot 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)python
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)python
© 2026 SixtyFPS GmbH