mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-28 10:00:33 +03:00
Merge pull request #5646 from radarhere/expand
This commit is contained in:
commit
5a9dacfc26
|
@ -33,6 +33,9 @@ def test_angle():
|
|||
with Image.open("Tests/images/test-card.png") as im:
|
||||
rotate(im, im.mode, angle)
|
||||
|
||||
im = hopper()
|
||||
assert_image_equal(im.rotate(angle), im.rotate(angle, expand=1))
|
||||
|
||||
|
||||
def test_zero():
|
||||
for angle in (0, 45, 90, 180, 270):
|
||||
|
|
|
@ -35,7 +35,13 @@ TODO
|
|||
Other Changes
|
||||
=============
|
||||
|
||||
TODO
|
||||
^^^^
|
||||
Speed improvement when rotating square images
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
TODO
|
||||
Starting with Pillow 3.3.0, the speed of rotating images by 90 or 270 degrees was
|
||||
improved by quickly returning :py:meth:`~PIL.Image.Image.transpose` instead, if the
|
||||
rotate operation allowed for expansion and did not specify a center or post-rotate
|
||||
translation.
|
||||
|
||||
Since the ``expand`` flag makes no difference for square images though, Pillow now
|
||||
uses this faster method for square images without the ``expand`` flag as well.
|
||||
|
|
|
@ -2074,10 +2074,8 @@ class Image:
|
|||
return self.copy()
|
||||
if angle == 180:
|
||||
return self.transpose(ROTATE_180)
|
||||
if angle == 90 and expand:
|
||||
return self.transpose(ROTATE_90)
|
||||
if angle == 270 and expand:
|
||||
return self.transpose(ROTATE_270)
|
||||
if angle in (90, 270) and (expand or self.width == self.height):
|
||||
return self.transpose(ROTATE_90 if angle == 90 else ROTATE_270)
|
||||
|
||||
# Calculate the affine matrix. Note that this is the reverse
|
||||
# transformation (from destination image to source) because we
|
||||
|
|
Loading…
Reference in New Issue
Block a user