Skip to content

image_viewer

image_viewer #

ImageViewer — one picture with an optional caption.

MAX_AXIS = 1600 module-attribute #

The longest side the picture is shown at, in pixels.

ImageViewer #

Bases: Component

A single image and its caption.

Any still image shows — HEIC, DNG, a panorama — as a JPEG of at most MAX_AXIS pixels.

cgui.ImageViewer(target.reference, caption="The marked spot")
Source code in capturegraph-ui/capturegraph_ui/viewers/image_viewer.py
class ImageViewer(Component):
    """A single ``image`` and its ``caption``.

    Any still image shows — HEIC, DNG, a panorama — as a JPEG of at most
    ``MAX_AXIS`` pixels.

    ```python
    cgui.ImageViewer(target.reference, caption="The marked spot")
    ```
    """

    image: cg.Image
    caption: str | None = None

    def html(self, render: Render) -> str:
        """A figure of the staged image."""
        return picture(
            render.stage(web_image(self.image, MAX_AXIS)),
            self.caption,
            None if self.caption is None else text(self.caption),
        )

html(render) #

A figure of the staged image.

Source code in capturegraph-ui/capturegraph_ui/viewers/image_viewer.py
def html(self, render: Render) -> str:
    """A figure of the staged image."""
    return picture(
        render.stage(web_image(self.image, MAX_AXIS)),
        self.caption,
        None if self.caption is None else text(self.caption),
    )