mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-22 05:53:22 +03:00
use one self.transform for rotation
This commit is contained in:
parent
7687ce829e
commit
709078efd1
17
PIL/Image.py
17
PIL/Image.py
|
@ -30,6 +30,7 @@ from PIL import VERSION, PILLOW_VERSION, _plugins
|
|||
|
||||
import logging
|
||||
import warnings
|
||||
import math
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -1581,8 +1582,7 @@ class Image(object):
|
|||
if angle == 270 and expand:
|
||||
return self.transpose(ROTATE_270)
|
||||
|
||||
if expand:
|
||||
import math
|
||||
|
||||
angle = - math.radians(angle)
|
||||
matrix = [
|
||||
round(math.cos(angle), 15), round(math.sin(angle), 15), 0.0,
|
||||
|
@ -1593,8 +1593,9 @@ class Image(object):
|
|||
(a, b, c, d, e, f) = matrix
|
||||
return a*x + b*y + c, d*x + e*y + f
|
||||
|
||||
# calculate output size
|
||||
w, h = self.size
|
||||
if expand:
|
||||
# calculate output size
|
||||
xx = []
|
||||
yy = []
|
||||
for x, y in ((0, 0), (w, 0), (w, h), (0, h)):
|
||||
|
@ -1611,16 +1612,6 @@ class Image(object):
|
|||
|
||||
return self.transform((w, h), AFFINE, matrix, resample)
|
||||
|
||||
if resample not in (NEAREST, BILINEAR, BICUBIC):
|
||||
raise ValueError("unknown resampling filter")
|
||||
|
||||
self.load()
|
||||
|
||||
if self.mode in ("1", "P"):
|
||||
resample = NEAREST
|
||||
|
||||
return self._new(self.im.rotate(angle, resample, expand))
|
||||
|
||||
def save(self, fp, format=None, **params):
|
||||
"""
|
||||
Saves this image under the given filename. If no format is
|
||||
|
|
Loading…
Reference in New Issue
Block a user