@@ -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 )
@@ -292,10 +292,10 @@ def pad(image, size, method=Image.Resampling.BICUBIC, color=None, centering=(0.5
292292 else :
293293 out = Image .new (image .mode , size , color )
294294 if resized .width != size [0 ]:
295- x = int ((size [0 ] - resized .width ) * max (0 , min (centering [0 ], 1 )))
295+ x = round ((size [0 ] - resized .width ) * max (0 , min (centering [0 ], 1 )))
296296 out .paste (resized , (x , 0 ))
297297 else :
298- y = int ((size [1 ] - resized .height ) * max (0 , min (centering [1 ], 1 )))
298+ y = round ((size [1 ] - resized .height ) * max (0 , min (centering [1 ], 1 )))
299299 out .paste (resized , (0 , y ))
300300 return out
301301
0 commit comments