Skip to content

Commit dff506c

Browse files
Merge pull request #302 from webfiltered/fix-cosntrain-image
Fix ConstrainImage increases size
2 parents e863cb5 + c5ee036 commit dff506c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

py/constrain_image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def constrain_image(self, images, max_width, max_height, min_width, min_height,
3535
current_width, current_height = img.size
3636
aspect_ratio = current_width / current_height
3737

38-
constrained_width = max(min(current_width, min_width), max_width)
39-
constrained_height = max(min(current_height, min_height), max_height)
38+
constrained_width = min(max(current_width, min_width), max_width)
39+
constrained_height = min(max(current_height, min_height), max_height)
4040

4141
if constrained_width / constrained_height > aspect_ratio:
4242
constrained_width = max(int(constrained_height * aspect_ratio), min_width)

0 commit comments

Comments
 (0)