diff --git a/servers/fastapi/api/v1/ppt/endpoints/outlines.py b/servers/fastapi/api/v1/ppt/endpoints/outlines.py index 6041bb7d..a9a811e3 100644 --- a/servers/fastapi/api/v1/ppt/endpoints/outlines.py +++ b/servers/fastapi/api/v1/ppt/endpoints/outlines.py @@ -1,3 +1,4 @@ +import asyncio import json from fastapi import APIRouter, HTTPException from fastapi.responses import StreamingResponse diff --git a/servers/fastapi/utils/image_utils.py b/servers/fastapi/utils/image_utils.py index b0d26057..7a4ecb29 100644 --- a/servers/fastapi/utils/image_utils.py +++ b/servers/fastapi/utils/image_utils.py @@ -53,6 +53,11 @@ def round_image_corners(image: Image.Image, radii: List[int]) -> Image.Image: ) w, h = image.size + + # Clamp border radius to not exceed half the width or height + max_radius = min(w // 2, h // 2) + clamped_radii = [min(radius, max_radius) for radius in radii] + # Ensure the image has an alpha channel (RGBA) if image.mode != "RGBA": image = image.convert("RGBA") @@ -64,7 +69,7 @@ def round_image_corners(image: Image.Image, radii: List[int]) -> Image.Image: rectangular_mask = Image.new("L", image.size, 255) # Process each corner - for i, radius in enumerate(radii): + for i, radius in enumerate(clamped_radii): if radius > 0: # Only process if radius is positive # Create a circle for this radius circle = Image.new("L", (radius * 2, radius * 2), 0) diff --git a/servers/nextjs/app/api/presentation_to_pptx_model/route.ts b/servers/nextjs/app/api/presentation_to_pptx_model/route.ts index c39a9c79..66a2b2da 100644 --- a/servers/nextjs/app/api/presentation_to_pptx_model/route.ts +++ b/servers/nextjs/app/api/presentation_to_pptx_model/route.ts @@ -105,6 +105,7 @@ async function postProcessSlidesAttributes(slidesAttributes: SlideAttributesResu const screenshotPath = await screenshotElement(element, screenshotsDir); element.imageSrc = screenshotPath; element.should_screenshot = false; + element.objectFit = 'cover'; element.element = undefined; } } @@ -701,7 +702,7 @@ async function getElementAttributes(element: ElementHandle): Promise): Promise { + // For top-left and bottom-right corners, use maxRadiusX + // For top-right and bottom-left corners, use maxRadiusY + const maxRadius = (index === 0 || index === 2) ? maxRadiusX : maxRadiusY; + return Math.max(0, Math.min(radius, maxRadius)); + }); + } } return borderRadiusValue; @@ -757,7 +772,7 @@ async function getElementAttributes(element: ElementHandle): Promise