mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Fixed ZeroDivisionError in thumbnail
This commit is contained in:
parent
4634eafe3c
commit
b8ec793898
|
@ -63,6 +63,12 @@ def test_aspect():
|
|||
assert im.size == (75, 23) # ratio is 3.260869565217
|
||||
|
||||
|
||||
def test_division_by_zero():
|
||||
im = Image.new("L", (200, 2))
|
||||
im.thumbnail((75, 75))
|
||||
assert im.size == (75, 1)
|
||||
|
||||
|
||||
def test_float():
|
||||
im = Image.new("L", (128, 128))
|
||||
im.thumbnail((99.9, 99.9))
|
||||
|
|
|
@ -2277,7 +2277,9 @@ class Image:
|
|||
if x / y >= aspect:
|
||||
x = round_aspect(y * aspect, key=lambda n: abs(aspect - n / y))
|
||||
else:
|
||||
y = round_aspect(x / aspect, key=lambda n: abs(aspect - x / n))
|
||||
y = round_aspect(
|
||||
x / aspect, key=lambda n: 0 if n == 0 else abs(aspect - x / n)
|
||||
)
|
||||
size = (x, y)
|
||||
|
||||
box = None
|
||||
|
|
Loading…
Reference in New Issue
Block a user