Skip to content

Update radii parameter type in round_image_corners#493

Open
HU-Bro wants to merge 1 commit intopresenton:mainfrom
HU-Bro:patch-1
Open

Update radii parameter type in round_image_corners#493
HU-Bro wants to merge 1 commit intopresenton:mainfrom
HU-Bro:patch-1

Conversation

@HU-Bro
Copy link
Copy Markdown

@HU-Bro HU-Bro commented Apr 3, 2026

Change the type of 'radii' parameter from List[int] to List[float] in round_image_corners function. This is part of fixing powerpoint export errors, together with

PptxAutoShapeBoxModel border_radius: Optional[int] = NoneOptional[float]

PptxPictureBoxModel border_radius: Optional[List[int]] = NoneOptional[List[float]]
https://github.com/presenton/presenton/tree/main/electron/servers/fastapi/services/pptx_presentation_creator.py apply_border_radius_to_shape(self, shape, border_radius: Optional[int])Optional[float]
https://github.com/presenton/presenton/tree/main/electron/servers/fastapi/utils/image_utils.py round_image_corners(image, radii: List[int])List[float]

Change the type of 'radii' parameter from List[int] to List[float] in round_image_corners function.
This is part of fixing powerpoint export errors, together with 

`PptxAutoShapeBoxModel` `border_radius: Optional[int] = None` → `Optional[float]`

PptxPictureBoxModel `border_radius: Optional[List[int]] = None` → `Optional[List[float]]`
 https://github.com/presenton/presenton/tree/main/electron/servers/fastapi/services/pptx_presentation_creator.py  `apply_border_radius_to_shape(self, shape, border_radius: Optional[int])` → `Optional[float]`
 https://github.com/presenton/presenton/tree/main/electron/servers/fastapi/utils/image_utils.py  `round_image_corners(image, radii: List[int])` → `List[float]`
Copilot AI review requested due to automatic review settings April 3, 2026 08:47
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 3, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the round_image_corners utility function to accept float border-radius values, aligning with broader work to address PowerPoint export border-radius type issues.

Changes:

  • Updated round_image_corners parameter type from List[int] to List[float].
Comments suppressed due to low confidence (1)

electron/servers/fastapi/utils/image_utils.py:53

  • radii is now typed as List[float], but the implementation uses each radius in Pillow APIs that require integers (e.g., Image.new size tuples and crop/paste coordinates). Passing non-integer floats will raise TypeError at runtime. Consider converting/clamping the incoming radii to non-negative integers (e.g., via rounding/flooring) before they’re used to create masks and compute coordinates.
def round_image_corners(image: Image.Image, radii: List[float]) -> Image.Image:
    if len(radii) != 4:
        raise ValueError(
            "Image Border Radius - radii must contain exactly 4 values for each corner"
        )

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.



def round_image_corners(image: Image.Image, radii: List[int]) -> Image.Image:
def round_image_corners(image: Image.Image, radii: List[float]) -> Image.Image:
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description mentions additional related type changes (e.g., PptxAutoShapeBoxModel.border_radius, PptxPictureBoxModel.border_radius, and apply_border_radius_to_shape), but this PR only changes the type hint here. Either update the description to match the actual scope, or include the other changes in this PR so the type updates remain consistent end-to-end.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants