mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +03:00
Speed up rotating square images by 90 or 270 degrees
This commit is contained in:
parent
6cb127c8cd
commit
438c3cc097
|
@ -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):
|
||||
|
|
|
@ -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