Skip to content

API Reference parrot_formdesigner.services.thumbnail

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_formdesigner.services.thumbnail

View source

Server-side thumbnail generation for image uploads (FEAT-460).

Uses Pillow to resize images to a bounded max size and re-encode them (WebP by default), persisting the result to blob storage. All CPU-bound Pillow work runs in a worker thread via asyncio.to_thread to avoid blocking the event loop.

Alias AbstractBlobStorage

Re-exported from parrot_formdesigner.services.blob_storage.AbstractBlobStorage.

Alias BlobMetadata

Re-exported from parrot_formdesigner.services.blob_storage.BlobMetadata.

Class ThumbnailService

Server-side thumbnail generator for image uploads.

Uses Pillow to resize images to 150x150 max, outputs WebP (quality 80). Persists thumbnails to blob storage and returns a relative URL.

Parameter Type Default Description
blob_storage AbstractBlobStorage Blob storage backend used to persist thumbnails.
max_width int 150 Maximum thumbnail width in pixels.
max_height int 150 Maximum thumbnail height in pixels.
quality int 80 Output encoding quality (0-100).
output_format str 'WEBP' Pillow format name used to encode the thumbnail (e.g. "WEBP").

Method ThumbnailService.generate

Generate and persist a thumbnail.

generate(image_bytes: bytes, metadata: BlobMetadata) -> str | None

Parameter Type Default Description
image_bytes bytes Raw bytes of the source image.
metadata BlobMetadata Metadata describing the original upload; used to derive thumbnail-specific metadata.

Returns: str | None — The thumbnail's blob_ref, or None if generation failed (e.g. corrupt image or unsupported format). Failures are logged as warnings and are non-fatal to the caller.

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally