Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make sure target_height is at least 1px #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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