Merge pull request #4410 from uploadcare/already-int

Math functions return int in Python 3
This commit is contained in:
Andrew Murray 2020-02-08 09:14:27 +11:00 committed by GitHub
commit d9e6abf8cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 7 deletions

View File

@ -25,6 +25,7 @@
# #
import itertools import itertools
import math
import os import os
import subprocess import subprocess
@ -701,14 +702,12 @@ def _get_optimize(im, info):
def _get_color_table_size(palette_bytes): def _get_color_table_size(palette_bytes):
# calculate the palette size for the header # calculate the palette size for the header
import math
if not palette_bytes: if not palette_bytes:
return 0 return 0
elif len(palette_bytes) < 9: elif len(palette_bytes) < 9:
return 1 return 1
else: else:
return int(math.ceil(math.log(len(palette_bytes) // 3, 2))) - 1 return math.ceil(math.log(len(palette_bytes) // 3, 2)) - 1
def _get_header_palette(palette_bytes): def _get_header_palette(palette_bytes):

View File

@ -2015,8 +2015,8 @@ class Image:
x, y = transform(x, y, matrix) x, y = transform(x, y, matrix)
xx.append(x) xx.append(x)
yy.append(y) yy.append(y)
nw = int(math.ceil(max(xx)) - math.floor(min(xx))) nw = math.ceil(max(xx)) - math.floor(min(xx))
nh = int(math.ceil(max(yy)) - math.floor(min(yy))) nh = math.ceil(max(yy)) - math.floor(min(yy))
# We multiply a translation matrix from the right. Because of its # We multiply a translation matrix from the right. Because of its
# special form, this is the same as taking the image of the # special form, this is the same as taking the image of the

View File

@ -298,7 +298,7 @@ def scale(image, factor, resample=Image.BICUBIC):
elif factor <= 0: elif factor <= 0:
raise ValueError("the factor must be greater than 0") raise ValueError("the factor must be greater than 0")
else: else:
size = (int(round(factor * image.width)), int(round(factor * image.height))) size = (round(factor * image.width), round(factor * image.height))
return image.resize(size, resample) return image.resize(size, resample)

View File

@ -614,7 +614,7 @@ def _save(im, fp, filename):
info = im.encoderinfo info = im.encoderinfo
dpi = [int(round(x)) for x in info.get("dpi", (0, 0))] dpi = [round(x) for x in info.get("dpi", (0, 0))]
quality = info.get("quality", 0) quality = info.get("quality", 0)
subsampling = info.get("subsampling", -1) subsampling = info.get("subsampling", -1)