1
0
mirror of https://github.com/django/django.git synced 2025-10-25 06:36:07 +00:00

Fixed #24948 -- Fixed crash when uploading bitmap images in forms.ImageField

This commit is contained in:
Andriy Sokolovskiy
2015-06-16 18:24:59 +03:00
committed by Tim Graham
parent fbc618c13c
commit cf6ce279c7
5 changed files with 35 additions and 6 deletions

View File

@@ -683,7 +683,9 @@ class ImageField(FileField):
# Annotating so subclasses can reuse it for their own validation
f.image = image
f.content_type = Image.MIME[image.format]
# Pillow doesn't detect the MIME type of all formats. In those
# cases, content_type will be None.
f.content_type = Image.MIME.get(image.format)
except Exception:
# Pillow doesn't recognize it as an image.
six.reraise(ValidationError, ValidationError(