@@ -37,7 +37,7 @@ def image_optimizer(image_data, output_size=None, resize_method=None):
37
37
Optimize an image that has not been saved to a file.
38
38
:param `image_data` is image data, e.g from request.FILES['image']
39
39
:param `output_size` is float pixel scale of image (width, height) or None, for example: (400, 300) # noqa: E501
40
- :param `resize_method` is string resize method, choices are: None, "thumbnail", or "cover" . # noqa: E501
40
+ :param `resize_method` is string resize method, choices are: None or resizeimage.resize() method argument values . # noqa: E501
41
41
:return optimized image data.
42
42
"""
43
43
if OPTIMIZED_IMAGE_METHOD == "pillow" :
@@ -50,20 +50,10 @@ def image_optimizer(image_data, output_size=None, resize_method=None):
50
50
# resize_method. 'thumbnail' is used by default
51
51
if output_size is not None :
52
52
53
- if resize_method not in ("thumbnail" , "cover" , None ):
54
- message = (
55
- "optimized_image_resize_method misconfigured, "
56
- "it's value must be 'thumbnail', 'cover' or None"
53
+ if resize_method :
54
+ image = resizeimage .resize (
55
+ method = resize_method , image = image , size = output_size ,
57
56
)
58
- raise Exception (message )
59
-
60
- elif resize_method == "thumbnail" :
61
- image = resizeimage .resize_thumbnail (
62
- image , output_size , resample = Image .LANCZOS
63
- )
64
-
65
- elif resize_method == "cover" :
66
- image = resizeimage .resize_cover (image , output_size , validate = False )
67
57
68
58
output_image = Image .new (
69
59
"RGBA" ,
0 commit comments