taolib.testing.file_storage.processing.thumbnail#

缩略图生成器。

使用 Pillow 生成多种规格的缩略图。

Attributes#

Classes#

PillowThumbnailGenerator

基于 Pillow 的缩略图生成器。

Module Contents#

taolib.testing.file_storage.processing.thumbnail.THUMBNAIL_DIMENSIONS: dict[taolib.testing.file_storage.models.enums.ThumbnailSize, tuple[int, int]]#
taolib.testing.file_storage.processing.thumbnail.SUPPORTED_IMAGE_TYPES#
class taolib.testing.file_storage.processing.thumbnail.PillowThumbnailGenerator#

基于 Pillow 的缩略图生成器。

supports(content_type: str) bool#

检查是否支持该内容类型。

async generate(source_data: bytes, content_type: str, sizes: list[taolib.testing.file_storage.models.enums.ThumbnailSize] | None = None) list[taolib.testing.file_storage.processing.protocols.ThumbnailOutput]#

生成缩略图(在线程池中执行 CPU 密集操作)。

_generate_sync(source_data: bytes, sizes: list[taolib.testing.file_storage.models.enums.ThumbnailSize]) list[taolib.testing.file_storage.processing.protocols.ThumbnailOutput]#

同步生成缩略图。