diff --git a/apps/html_template_editor/validators.py b/apps/html_template_editor/validators.py index fd0676d2c..220b7ce5c 100644 --- a/apps/html_template_editor/validators.py +++ b/apps/html_template_editor/validators.py @@ -7,11 +7,19 @@ def validate_logo_image(image): max_width = 300 megabyte_limit = 5.0 * 1024 * 1024 + allowed_image_formats = ['JPEG', 'PNG'] - width, height = Image.open(image).size + img = Image.open(image) + width, height = img.size image_file_size = image.tell() + image_file_format = img.format + + if image_file_format not in allowed_image_formats: + raise ValidationError( + _("Allowed image format is %(image_formats)s "), + params={'image_formats': ', '.join(allowed_image_formats)}, + ) - print(width, image_file_size) if width > max_width: raise ValidationError( _("Width is larger than what is allowed %(max_width)s px"),