web_image
web_image
#
Browser-ready pictures: any still image as a JPEG a page can show.
- Fit. A JPEG already within the size a viewer asks for is shown as it is.
- Transcode. Anything else — HEIC, DNG, a panorama, a larger JPEG — is decoded, shrunk and re-encoded once by a memoized function, so a rebuilt page reuses the result.
thumbnail and mosaic are the same transcode for a value that leaves the
page, such as an interceptor's _metadata._thumbnail.
THUMBNAIL_AXIS = 320
module-attribute
#
The longest side of a thumbnail, in pixels, and the side of a mosaic.
mosaic(images, side=2)
#
side × side of images, spread evenly through them, tiled into one thumbnail.
Each tile is cropped square; fewer images than tiles leave the last tiles blank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images
|
Array[Picture]
|
The pictures to choose from, in order; |
required |
side
|
int
|
How many tiles across and down. |
2
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in capturegraph-ui/capturegraph_ui/viewers/web_image.py
thumbnail(image)
#
A JPEG preview of image, its longest side THUMBNAIL_AXIS pixels.
@cgserver.intercept(Survey, lambda s: s.sessions.for_each()._metadata._thumbnail)
def session_thumbnail(node: Session) -> cg.Thumbnail:
return cgui.thumbnail(node.photo)
Source code in capturegraph-ui/capturegraph_ui/viewers/web_image.py
web_image(image, max_axis)
#
image as a JPEG whose longest side is at most max_axis pixels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
StillImageFile
|
Any still image. |
required |
max_axis
|
int
|
The longest side to show, in pixels. |
required |
Returns:
| Type | Description |
|---|---|
StillImageFile
|
|
Source code in capturegraph-ui/capturegraph_ui/viewers/web_image.py
web_images(images, max_axis)
#
Each of images as web_image makes it, transcoded in parallel.
An image that cannot be decoded comes back Missing.
Source code in capturegraph-ui/capturegraph_ui/viewers/web_image.py
web_jpeg(image, max_axis)
#
image re-encoded as a JPEG, its longest side shrunk to max_axis pixels.