| Total Complexity | 5 |
| Total Lines | 27 |
| Duplicated Lines | 0 % |
| 1 | """ |
||
| 8 | class RotateFilter(ImagineFilterInterface): |
||
| 9 | """ |
||
| 10 | Rotate filter |
||
| 11 | """ |
||
| 12 | angle = None |
||
| 13 | |||
| 14 | def __init__(self, **kwargs): |
||
| 15 | """ |
||
| 16 | :param kwargs: dict |
||
| 17 | """ |
||
| 18 | if 'angle' in kwargs and isinstance(kwargs['angle'], (int, float)): |
||
| 19 | self.angle = kwargs.get('angle', 0) |
||
| 20 | else: |
||
| 21 | raise ValueError('Unsupported angle format or angle doesn\'t set') |
||
| 22 | |||
| 23 | def apply(self, resource): |
||
| 24 | """ |
||
| 25 | Apply filter to resource |
||
| 26 | :param resource: Image |
||
| 27 | :return: Image |
||
| 28 | """ |
||
| 29 | if not isinstance(resource, Image.Image): |
||
| 30 | raise ValueError('Unknown resource format') |
||
| 31 | |||
| 32 | resource = resource.rotate(self.angle, expand=True) |
||
| 33 | |||
| 34 | return resource |
||
| 35 |