From 470da1c6de0c8a2eb297a56388c02d013a098da3 Mon Sep 17 00:00:00 2001 From: "neiljp (Neil Pilgrim)" Date: Sun, 20 Aug 2017 19:22:51 -0700 Subject: [PATCH] Image.rotate: Adjust variable use to avoid None & add comment re int/float. --- PIL/Image.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/PIL/Image.py b/PIL/Image.py index c94c8b47e..f826588c5 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -1791,9 +1791,13 @@ class Image(object): w, h = self.size if translate is None: - translate = [0, 0] + post_trans = (0, 0) + else: + post_trans = translate if center is None: - center = [w / 2.0, h / 2.0] + rotn_center = (w / 2.0, h / 2.0) # FIXME These should be rounded to ints? + else: + rotn_center = center angle = - math.radians(angle) matrix = [ @@ -1805,10 +1809,10 @@ class Image(object): (a, b, c, d, e, f) = matrix return a*x + b*y + c, d*x + e*y + f - matrix[2], matrix[5] = transform(-center[0] - translate[0], - -center[1] - translate[1], matrix) - matrix[2] += center[0] - matrix[5] += center[1] + matrix[2], matrix[5] = transform(-rotn_center[0] - post_trans[0], + -rotn_center[1] - post_trans[1], matrix) + matrix[2] += rotn_center[0] + matrix[5] += rotn_center[1] if expand: # calculate output size