mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-14 05:36:48 +03:00
ImageOps.contain function finding new size issue
This commit is contained in:
parent
4dd678a2e7
commit
be9224f285
|
@ -255,11 +255,11 @@ def contain(image, size, method=Image.Resampling.BICUBIC):
|
||||||
|
|
||||||
if im_ratio != dest_ratio:
|
if im_ratio != dest_ratio:
|
||||||
if im_ratio > dest_ratio:
|
if im_ratio > dest_ratio:
|
||||||
new_height = int(image.height / image.width * size[0])
|
new_height = round(image.height / image.width * size[0])
|
||||||
if new_height != size[1]:
|
if new_height != size[1]:
|
||||||
size = (size[0], new_height)
|
size = (size[0], new_height)
|
||||||
else:
|
else:
|
||||||
new_width = int(image.width / image.height * size[1])
|
new_width = round(image.width / image.height * size[1])
|
||||||
if new_width != size[0]:
|
if new_width != size[0]:
|
||||||
size = (new_width, size[1])
|
size = (new_width, size[1])
|
||||||
return image.resize(size, resample=method)
|
return image.resize(size, resample=method)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user