Skip to content

Image Helpers

rerun

class ImageEncoded

Bases: AsComponents

A monochrome or color image encoded with a common format (PNG, JPEG, etc.).

The encoded image can be loaded from either a file using its path or provided directly via contents.

def __init__(*, path=None, contents=None, format=None, draw_order=None)

Create a new image with a given format.

PARAMETER DESCRIPTION
path

A path to a file stored on the local filesystem. Mutually exclusive with contents.

TYPE: str | Path | None DEFAULT: None

contents

The contents of the file. Can be a BufferedReader, BytesIO, or bytes. Mutually exclusive with path.

TYPE: bytes | IO[bytes] | None DEFAULT: None

format

The format of the image file. If not provided, it will be inferred from the file extension.

TYPE: ImageFormat | None DEFAULT: None

draw_order

An optional floating point value that specifies the 2D drawing order. Objects with higher values are drawn on top of those with lower values.

TYPE: DrawOrderLike | None DEFAULT: None