Make ratio comparison more explicit

This commit is contained in:
Alex Xu 2022-01-17 13:47:47 -08:00 committed by GitHub
parent b70da17f80
commit 7df96e86eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -138,8 +138,11 @@ def scaleCropImage(image, size):
widthDev, heightDev = size
widthImg, heightImg = image.size
imgRatio = float(widthImg) / float(heightImg)
devRatio = float(widthDev) / float(heightDev)
# don't crop 2 page spreads.
if (float(widthImg) / float(heightImg)) > (float(widthDev) / float(heightDev)):
if imgRatio > devRatio:
return resizeImage(image, size)
return ImageOps.fit(image, size, Image.ANTIALIAS)