Skip to content

capturegraph.procedures.toolkits.metadata.thumbnail_manager #

Thumbnail Management Toolkit#

This module provides utilities for managing thumbnail images associated with directories and capture sessions. Thumbnails are used for preview purposes in the app and help users quickly identify and organize their captured data.

Thumbnail images are automatically associated with directories and can be set, retrieved, and cached for efficient display in user interfaces.

set_thumbnail(directory, thumbnail, skip_if_exists) #

Sets a thumbnail image for a directory.

Associates a thumbnail image with the specified directory, which will be used for preview purposes in the app. Thumbnails help users quickly identify and navigate through their captured data.

Parameters:

Name Type Description Default
directory Procedure[PDirectory]

The directory to set the thumbnail for

required
thumbnail Procedure[PImageThumbnail]

The thumbnail image procedure that generates the thumbnail

required
skip_if_exists bool

Whether to skip setting if a thumbnail already exists

required

Returns:

Type Description
Procedure[PVoid]

A procedure that saves the thumbnail to the directory's thumbnail file

Example
import capturegraph.procedures as cgp

# Set a thumbnail for a session directory
session = root.new_session("my_session")
thumbnail = cgp.ConvertImageToThumbnail(image=primary_image)
cgp.set_thumbnail(session, thumbnail, skip_if_exists=True)
Source code in capturegraph-lib/capturegraph/procedures/toolkits/metadata/thumbnail_manager.py
def set_thumbnail(
    directory: Procedure[PDirectory],
    thumbnail: Procedure[PImageThumbnail],
    skip_if_exists: bool,
) -> Procedure[PVoid]:
    """
    Sets a thumbnail image for a directory.

    Associates a thumbnail image with the specified directory, which will be
    used for preview purposes in the app. Thumbnails help users quickly
    identify and navigate through their captured data.

    Args:
        directory (Procedure[PDirectory]): The directory to set the thumbnail for
        thumbnail (Procedure[PImageThumbnail]): The thumbnail image procedure that generates the thumbnail
        skip_if_exists (bool): Whether to skip setting if a thumbnail already exists

    Returns:
        A procedure that saves the thumbnail to the directory's thumbnail file

    Example:
        ```python
        import capturegraph.procedures as cgp

        # Set a thumbnail for a session directory
        session = root.new_session("my_session")
        thumbnail = cgp.ConvertImageToThumbnail(image=primary_image)
        cgp.set_thumbnail(session, thumbnail, skip_if_exists=True)
        ```
    """
    return (
        directory.get_thumbnail_file()
        .save(procedure=thumbnail, skip_if_exists=skip_if_exists)
        .set_label("Set Thumbnail")
    )