From a42beccee7f2c10277c28a6f6ef24fc8d9047d62 Mon Sep 17 00:00:00 2001 From: storesource <36395224+storesource@users.noreply.github.com> Date: Mon, 26 Mar 2018 19:29:44 +0530 Subject: [PATCH] Enabling background colour parameter on rotate Enabling the user to choose the background colour of the final rotated image rather than just black. parameter added: backgroundcolor --- src/PIL/Image.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 379a1d8a6..657141ba2 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1749,7 +1749,7 @@ class Image(object): return self._new(self.im.resize(size, resample, box)) def rotate(self, angle, resample=NEAREST, expand=0, center=None, - translate=None): + translate=None, backgroundcolor=None): """ Returns a rotated copy of this image. This method returns a copy of this image, rotated the given number of degrees counter @@ -1771,6 +1771,7 @@ class Image(object): :param center: Optional center of rotation (a 2-tuple). Origin is the upper left corner. Default is the center of the image. :param translate: An optional post-rotate translation (a 2-tuple). + :param backgroundcolor: An optional color for the color outside the transformed image :returns: An :py:class:`~PIL.Image.Image` object. """ @@ -1851,7 +1852,7 @@ class Image(object): matrix) w, h = nw, nh - return self.transform((w, h), AFFINE, matrix, resample) + return self.transform((w, h), AFFINE, matrix, resample, fillcolor=backgroundcolor) def save(self, fp, format=None, **params): """