Skip to content

Commit 54f3dc6

Browse files
committed
Math functions return int in Python 3
1 parent 81ea2b3 commit 54f3dc6

4 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/PIL/GifImagePlugin.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#
2626

2727
import itertools
28+
import math
2829
import os
2930
import subprocess
3031

@@ -701,14 +702,12 @@ def _get_optimize(im, info):
701702

702703
def _get_color_table_size(palette_bytes):
703704
# calculate the palette size for the header
704-
import math
705-
706705
if not palette_bytes:
707706
return 0
708707
elif len(palette_bytes) < 9:
709708
return 1
710709
else:
711-
return int(math.ceil(math.log(len(palette_bytes) // 3, 2))) - 1
710+
return math.ceil(math.log(len(palette_bytes) // 3, 2)) - 1
712711

713712

714713
def _get_header_palette(palette_bytes):

src/PIL/Image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,8 +2015,8 @@ def transform(x, y, matrix):
20152015
x, y = transform(x, y, matrix)
20162016
xx.append(x)
20172017
yy.append(y)
2018-
nw = int(math.ceil(max(xx)) - math.floor(min(xx)))
2019-
nh = int(math.ceil(max(yy)) - math.floor(min(yy)))
2018+
nw = math.ceil(max(xx)) - math.floor(min(xx))
2019+
nh = math.ceil(max(yy)) - math.floor(min(yy))
20202020

20212021
# We multiply a translation matrix from the right. Because of its
20222022
# special form, this is the same as taking the image of the

src/PIL/ImageOps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def scale(image, factor, resample=Image.BICUBIC):
298298
elif factor <= 0:
299299
raise ValueError("the factor must be greater than 0")
300300
else:
301-
size = (int(round(factor * image.width)), int(round(factor * image.height)))
301+
size = (round(factor * image.width), round(factor * image.height))
302302
return image.resize(size, resample)
303303

304304

src/PIL/JpegImagePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ def _save(im, fp, filename):
614614

615615
info = im.encoderinfo
616616

617-
dpi = [int(round(x)) for x in info.get("dpi", (0, 0))]
617+
dpi = [round(x) for x in info.get("dpi", (0, 0))]
618618

619619
quality = info.get("quality", 0)
620620
subsampling = info.get("subsampling", -1)

0 commit comments

Comments
 (0)