From fed4b52171c865ec45916699f5f13ac3a2c3c2cb Mon Sep 17 00:00:00 2001 From: wiredfool Date: Sun, 1 Jan 2017 11:11:10 +0000 Subject: [PATCH] Disable fastpath when using center or translate --- PIL/Image.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/PIL/Image.py b/PIL/Image.py index b86fae814..f49834e5b 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -1582,15 +1582,17 @@ class Image(object): angle = angle % 360.0 - # Fast paths regardless of filter - if angle == 0: - 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) + # Fast paths regardless of filter, as long as we're not + # translating or changing the center. + if not (center or translate): + if angle == 0: + 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) # Calculate the affine matrix. Note that this is the reverse # transformation (from destination image to source) because we