From 6bb03a677760a15b71a76b7730cd65e725264760 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Wed, 22 Oct 2014 10:38:12 +0100 Subject: [PATCH] Treat MPO formatted images like JPEG. Fixes #729 --- wagtail/wagtailimages/fields.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/wagtail/wagtailimages/fields.py b/wagtail/wagtailimages/fields.py index 0d22a9020b..605d332ac0 100644 --- a/wagtail/wagtailimages/fields.py +++ b/wagtail/wagtailimages/fields.py @@ -85,15 +85,19 @@ class WagtailImageField(ImageField): # Couldn't get the PIL image, skip checking the internal file format return - image_format = extension - if extension == 'jpg': - image_format = 'jpeg' + image_format = extension.upper() + if image_format == 'JPG': + image_format = 'JPEG' + + internal_image_format = image.format.upper() + if internal_image_format == 'MPO': + internal_image_format = 'JPEG' # Check that the internal format matches the extension # It is possible to upload PSD files if their extension is set to jpg, png or gif. This should catch them out - if image.format.upper() != image_format.upper(): + if internal_image_format != image_format: raise ValidationError(self.error_messages['invalid_image_known_format'] % ( - image_format.upper() + image_format, ), code='invalid_image_known_format') def check_image_file_size(self, f):