Exif rotation, description update
This commit is contained in:
parent
da5fdc3e4f
commit
77a88c093d
@ -26,7 +26,7 @@ from .preview_image import handle as preview_image_handler
|
||||
TOOL_REGISTRY = [
|
||||
Tool(
|
||||
name="read_image",
|
||||
description="Reads an image from the disk and returns it as a full size image content object.",
|
||||
description="Reads an image from the disk and returns it as a full size image.",
|
||||
schema={
|
||||
"type": "object",
|
||||
"properties": {"path": {"type": "string", "description": "Path to the image file"}},
|
||||
@ -75,7 +75,7 @@ TOOL_REGISTRY = [
|
||||
),
|
||||
Tool(
|
||||
name="preview_image",
|
||||
description="Generates small thumbnails (~70 tokens) and detailed info for images. Can take file paths, or indices/ranges from a contact sheet.",
|
||||
description="Generates small thumbnails and provides detailed info for images. Can take file paths, or indices/ranges from a contact sheet.",
|
||||
schema={
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@ -4,7 +4,7 @@ import io
|
||||
import datetime
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
from PIL import Image, ImageDraw, ImageFont, ImageOps
|
||||
from tools.utils import format_relative_time, ToolError, COMMON_FONTS, get_file_info_list, sort_file_list, get_paginated_list
|
||||
|
||||
logger = logging.getLogger("MattCP")
|
||||
@ -83,6 +83,8 @@ async def handle(args: Dict[str, Any]):
|
||||
|
||||
try:
|
||||
with Image.open(full_path) as img:
|
||||
# Apply EXIF orientation to fix sideways images
|
||||
img = ImageOps.exif_transpose(img)
|
||||
img.thumbnail((thumb_size, thumb_size))
|
||||
off_x = (thumb_size - img.width) // 2
|
||||
off_y = (thumb_size - img.height) // 2
|
||||
|
||||
@ -5,7 +5,7 @@ import io
|
||||
import datetime
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Tuple
|
||||
from PIL import Image
|
||||
from PIL import Image, ImageOps
|
||||
from tools.utils import format_relative_time, ToolError, get_file_info_list, sort_file_list
|
||||
|
||||
logger = logging.getLogger("MattCP")
|
||||
@ -115,6 +115,8 @@ async def handle(args: Dict[str, Any]):
|
||||
try:
|
||||
stats = file_path.stat()
|
||||
with Image.open(file_path) as img:
|
||||
# Apply EXIF orientation to fix sideways images
|
||||
img = ImageOps.exif_transpose(img)
|
||||
orig_w, orig_h = img.size
|
||||
target_w, target_h = calculate_patch_dimensions(orig_w, orig_h)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user