From a456e2d2cb8728764b9726290100ba6b8744702e Mon Sep 17 00:00:00 2001
From: Felix Dreissig <f30@f30.me>
Date: Tue, 26 Mar 2019 12:55:00 +0100
Subject: [PATCH 2/2] Fixed #30252 -- Reopen uploaded image after verify()
According to the Pillow docs, "you must reopen the image file" if you
want to use it after calling verify().
---
django/forms/fields.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/django/forms/fields.py b/django/forms/fields.py
index a977256525..7aef2ae91e 100644
a
|
b
|
class ImageField(FileField):
|
631 | 631 | image.verify() |
632 | 632 | |
633 | 633 | # Annotating so subclasses can reuse it for their own validation |
634 | | f.image = image |
| 634 | # The original `image` is not usable anymore after calling verify() |
| 635 | f.image = Image.open(file) |
635 | 636 | # Pillow doesn't detect the MIME type of all formats. In those |
636 | 637 | # cases, content_type will be None. |
637 | 638 | f.content_type = Image.MIME.get(image.format) |