NoteThe API detects each image’s format from its bytes.
typesafe_sdk.Asset
module-attribute
An asset referenced from request content; currently only images are supported.
typesafe_sdk.Image
dataclass
An image asset backed by image file bytes, or a path to an image file.
Examples:
From a file path:
pil extra):
bytes first:
data
instance-attribute
Image contents, represented as one of:
- raw bytes (anything supporting the
Bufferprotocol) - path-like object pointing at the image on the filesystem
from_base64
classmethod
Create an Image instance from a base64-encoded image bytes.
Parameters:
-
data(str | Buffer) – The image file bytes, base64-encoded, as text or an ASCII buffer. Whitespace, such as the line breaks of wrapped base64, is ignored.
-
TypeSafeError– The data isn’t valid base64 text.
from_pil
classmethod
Create an Image instance from a Pillow image.
Parameters:
-
image(PIL.Image.Image) – The Pillow image to encode. -
format(str, default:'jpeg') – The image format to save as, by its Pillow name.
-
TypeSafeError– Pillow can’t encode the image in this format.

