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

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