express.render.image

express.render.image(self, _fn=None, *, delete_file=False)

Reactively render a image file as an HTML image.

Parameters

delete_file: bool = False

If True, the image file will be deleted after rendering.

Returns

Type Description
A decorator for a function that returns an ImgData object.

Tip

The name of the decorated function (or @output(id=...)) should match the id of a output_image container (see output_image for example usage).

See Also

Examples

#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400

## file: app.py
from shiny.express import render


@render.image
def image():
    from pathlib import Path

    dir = Path(__file__).resolve().parent
    img = {"src": str(dir / "posit-logo.png"), "width": "100px"}
    return img