Skip to content

Commit

Permalink
make sure target_height is at least 1px
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTango committed Mar 17, 2023
1 parent 8ad7bff commit c0d869d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions news/75.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
make sure target_height is at least 1px [MrTango]
5 changes: 2 additions & 3 deletions plone/scale/scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,16 +259,15 @@ def _calculate_all_dimensions(
width = float(original_width) / float(original_height) * height
elif height is None:
height = float(original_height) / float(original_width) * width

# keep aspect ratio of original
target_width = original_width
target_height = original_height
if target_width > width:
target_height = int(max(target_height * width / target_width, 1))
target_width = int(width)
target_width = int(width) or 1
if target_height > height:
target_width = int(max(target_width * height / target_height, 1))
target_height = int(height)
target_height = int(height) or 1

dimensions.target_width = target_width
dimensions.target_height = target_height
Expand Down

0 comments on commit c0d869d

Please sign in to comment.