From 66e75249247d6ccc154906cb2d949f76fa75605a Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Wed, 22 Aug 2018 03:15:02 -0400 Subject: [PATCH] Add support for the fillcolor argument to the rotate transformation. Signed-off-by: Roberto Rosario --- HISTORY.rst | 2 ++ mayan/apps/converter/transformations.py | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 723055927d..4bc22ed9d1 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -84,6 +84,8 @@ - Update forum link in the about menu. - Only show the settings namespace list link where it is relevant. +- Add support for the fillcolor argument to the rotate + transformation. 3.0.1 (2018-07-08) ================= diff --git a/mayan/apps/converter/transformations.py b/mayan/apps/converter/transformations.py index f2a83cfc68..140f64a987 100644 --- a/mayan/apps/converter/transformations.py +++ b/mayan/apps/converter/transformations.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals import logging -from PIL import Image, ImageFilter +from PIL import Image, ImageColor, ImageFilter from django.utils.six import text_type from django.utils.translation import string_concat, ugettext_lazy as _ @@ -202,7 +202,7 @@ class TransformationResize(BaseTransformation): class TransformationRotate(BaseTransformation): - arguments = ('degrees',) + arguments = ('degrees', 'fillcolor') label = _('Rotate') name = 'rotate' @@ -214,8 +214,14 @@ class TransformationRotate(BaseTransformation): if self.degrees == 0: return self.image + if self.fillcolor: + fillcolor = ImageColor.getrgb(self.fillcolor) + else: + fillcolor = None + return self.image.rotate( - 360 - self.degrees, resample=Image.BICUBIC, expand=True + angle=360 - self.degrees, resample=Image.BICUBIC, expand=True, + fillcolor=fillcolor )