bootstack.images.Image#
- class bootstack.images.Image(*, pil=None, path=None, data=None, icon=None)#
Bases:
objectA toolkit-free image handle, rendered for display only when used.
An
Imagecarries a source — a file, raw bytes, an in-memory picture, or a deferred icon — without creating any display resource up front. The picture is rendered the moment it is handed to a widget (viaimage=), so a handle can be built before an application is running and shared across widgets.Build one with
Image.open,Image.from_bytes, orImage.from_pil, or useget_iconfor a Bootstrap icon. Readwidthandheightat any time.File and byte sources accept the common raster image formats — PNG, JPEG, GIF, BMP, TIFF, WebP, and ICO. (Animated formats load their first frame.)
- classmethod from_bytes(data)#
Create an image handle from raw, encoded image bytes.
- classmethod from_pil(image)#
Create an image handle from an in-memory Pillow image.
Useful when you have already loaded or manipulated a picture with Pillow (resizing, filtering, compositing) and want to display the result.
- Parameters:
image (_PILImage) – A Pillow image object to wrap.
- Returns:
A new image handle.
- Return type:
- classmethod open(path)#
Create an image handle from a file on disk.
The file is decoded lazily, so the path is not read until the image is displayed or its size is queried.