Add support for the fillcolor argument to the rotate transformation.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-08-22 03:15:02 -04:00
parent a4552cf415
commit 66e7524924
2 changed files with 11 additions and 3 deletions

View File

@@ -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)
=================

View File

@@ -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
)