Skip to content

Commit be9224f

Browse files
committed
ImageOps.contain function finding new size issue
1 parent 4dd678a commit be9224f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/PIL/ImageOps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,11 @@ def contain(image, size, method=Image.Resampling.BICUBIC):
255255

256256
if im_ratio != dest_ratio:
257257
if im_ratio > dest_ratio:
258-
new_height = int(image.height / image.width * size[0])
258+
new_height = round(image.height / image.width * size[0])
259259
if new_height != size[1]:
260260
size = (size[0], new_height)
261261
else:
262-
new_width = int(image.width / image.height * size[1])
262+
new_width = round(image.width / image.height * size[1])
263263
if new_width != size[0]:
264264
size = (new_width, size[1])
265265
return image.resize(size, resample=method)

0 commit comments

Comments
 (0)