mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
- `MetadataModule` is stateless and needed in places where the `InvocationContext` is not available, so have not made it a `service` - Handles loading/parsing/building metadata, and creating png info objects - added tests for MetadataModule - Lifted thumbnail stuff to util
16 lines
467 B
Python
16 lines
467 B
Python
import os
|
|
from PIL import Image
|
|
|
|
|
|
def get_thumbnail_name(image_name: str) -> str:
|
|
"""Formats given an image name, returns the appropriate thumbnail image name"""
|
|
thumbnail_name = os.path.splitext(image_name)[0] + ".webp"
|
|
return thumbnail_name
|
|
|
|
|
|
def make_thumbnail(image: Image.Image, size: int = 256) -> Image.Image:
|
|
"""Makes a thumbnail from a PIL Image"""
|
|
thumbnail = image.copy()
|
|
thumbnail.thumbnail(size=(size, size))
|
|
return thumbnail
|