mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-16 11:12:29 +03:00
Image.rotate: Adjust variable use to avoid None & add comment re int/float.
This commit is contained in:
parent
6f69379fdc
commit
470da1c6de
16
PIL/Image.py
16
PIL/Image.py
|
@ -1791,9 +1791,13 @@ class Image(object):
|
||||||
w, h = self.size
|
w, h = self.size
|
||||||
|
|
||||||
if translate is None:
|
if translate is None:
|
||||||
translate = [0, 0]
|
post_trans = (0, 0)
|
||||||
|
else:
|
||||||
|
post_trans = translate
|
||||||
if center is None:
|
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)
|
angle = - math.radians(angle)
|
||||||
matrix = [
|
matrix = [
|
||||||
|
@ -1805,10 +1809,10 @@ class Image(object):
|
||||||
(a, b, c, d, e, f) = matrix
|
(a, b, c, d, e, f) = matrix
|
||||||
return a*x + b*y + c, d*x + e*y + f
|
return a*x + b*y + c, d*x + e*y + f
|
||||||
|
|
||||||
matrix[2], matrix[5] = transform(-center[0] - translate[0],
|
matrix[2], matrix[5] = transform(-rotn_center[0] - post_trans[0],
|
||||||
-center[1] - translate[1], matrix)
|
-rotn_center[1] - post_trans[1], matrix)
|
||||||
matrix[2] += center[0]
|
matrix[2] += rotn_center[0]
|
||||||
matrix[5] += center[1]
|
matrix[5] += rotn_center[1]
|
||||||
|
|
||||||
if expand:
|
if expand:
|
||||||
# calculate output size
|
# calculate output size
|
||||||
|
|
Loading…
Reference in New Issue
Block a user