Skip to content

meringue.thumbnail.shortcuts ¤

get_thumbnail ¤

get_thumbnail(
    file_path: Path,
    job_chain: JobChainType,
    out_format: str = m_settings.THUMBNAIL_DEFAULT_FORMAT,
    **kwargs
) -> str

Shortcut to make single image preview

Attributes:

  • file_path

    Source file path.

  • job_chain

    Thumbnail job chain.

  • format

    Output image format.

  • **kwargs

    Output image save extra params.

Returns:

  • str

    Thumbnail url.

Source code in meringue/thumbnail/shortcuts.py
def get_thumbnail(
    file_path: Path,
    job_chain: JobChainType,
    out_format: str = m_settings.THUMBNAIL_DEFAULT_FORMAT,
    **kwargs,
) -> str:
    """
    Shortcut to make single image preview

    Attributes:
        file_path: Source file path.
        job_chain: Thumbnail job chain.
        format: Output image format.
        **kwargs: Output image save extra params.

    Returns:
        Thumbnail url.
    """

    if not file_path.exists():
        msg = f"File `{file_path}` not found."
        logger.error(msg)
        return _dummyimage(job_chain)

    thumbnailer = DefaultThumbnailer(file_path, job_chain=job_chain)
    thumbnail_image = thumbnailer.get_thumbnail(out_format, **kwargs)
    return thumbnail_image.url