mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
Math functions return int in Python 3
This commit is contained in:
parent
81ea2b32af
commit
54f3dc6006
|
@ -25,6 +25,7 @@
|
|||
#
|
||||
|
||||
import itertools
|
||||
import math
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
|
@ -701,14 +702,12 @@ def _get_optimize(im, info):
|
|||
|
||||
def _get_color_table_size(palette_bytes):
|
||||
# calculate the palette size for the header
|
||||
import math
|
||||
|
||||
if not palette_bytes:
|
||||
return 0
|
||||
elif len(palette_bytes) < 9:
|
||||
return 1
|
||||
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):
|
||||
|
|
|
@ -2015,8 +2015,8 @@ class Image:
|
|||
x, y = transform(x, y, matrix)
|
||||
xx.append(x)
|
||||
yy.append(y)
|
||||
nw = int(math.ceil(max(xx)) - math.floor(min(xx)))
|
||||
nh = int(math.ceil(max(yy)) - math.floor(min(yy)))
|
||||
nw = math.ceil(max(xx)) - math.floor(min(xx))
|
||||
nh = math.ceil(max(yy)) - math.floor(min(yy))
|
||||
|
||||
# We multiply a translation matrix from the right. Because of its
|
||||
# special form, this is the same as taking the image of the
|
||||
|
|
|
@ -298,7 +298,7 @@ def scale(image, factor, resample=Image.BICUBIC):
|
|||
elif factor <= 0:
|
||||
raise ValueError("the factor must be greater than 0")
|
||||
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)
|
||||
|
||||
|
||||
|
|
|
@ -614,7 +614,7 @@ def _save(im, fp, filename):
|
|||
|
||||
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)
|
||||
subsampling = info.get("subsampling", -1)
|
||||
|
|
Loading…
Reference in New Issue
Block a user