Update radii parameter type in round_image_corners#493
Update radii parameter type in round_image_corners#493HU-Bro wants to merge 1 commit intopresenton:mainfrom
Conversation
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]`
There was a problem hiding this comment.
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_cornersparameter type fromList[int]toList[float].
Comments suppressed due to low confidence (1)
electron/servers/fastapi/utils/image_utils.py:53
radiiis now typed asList[float], but the implementation uses eachradiusin Pillow APIs that require integers (e.g.,Image.newsize tuples andcrop/pastecoordinates). Passing non-integer floats will raiseTypeErrorat 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: |
There was a problem hiding this comment.
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.
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
PptxAutoShapeBoxModelborder_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]