juno.preview¶
Present arbitrary files or in-memory data in Juno’s modal preview.
The preview is the same QuickLook-based modal that pops up for
matplotlib figures from a script, but reachable from any context —
scripts and notebooks alike. Calling show() repeatedly during
a single run appends each new entry to the already-open modal
rather than replacing it; you can swipe (or use the navigation
controls) to step between them. For inline rendering inside a
notebook cell, use IPython.display instead.
Typical usage:
from juno import preview
preview.show("/path/to/photo.jpg")
preview.show(pil_image)
preview.show(numpy_rgb_array)
preview.show(matplotlib_figure)
preview.show(png_bytes, mime="image/png")
- juno.preview.show(source, *, mime=None)¶
Present
sourcein the modal preview.- Parameters:
source (Any) – What to preview. Accepts a file path (
stroros.PathLike), raw encoded bytes (bytes,bytearray,memoryview), aPIL.Image.Image, anumpy.ndarray, or amatplotlib.figure.Figure.mime (str | None) – Optional MIME type hint, used only when
sourceis raw bytes that cannot be identified by their magic-byte prefix (e.g."image/heic","video/mp4").
- Raises:
TypeError – If
mimeis not a string.PreviewError – If
sourceis an unsupported type, the referenced file does not exist, the byte payload is empty or cannot be identified, or the encoding step fails (e.g. unsupported NumPy dtype or shape).
- Return type:
None