mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #11158 - get_image_dimensions very slow/incorrect after 1 call
Thanks to kua for the report, and to kua, SmileyChris and SAn for the patch git-svn-id: http://code.djangoproject.com/svn/django/trunk@13715 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
443cb9b6ed
commit
76249c3964
2 changed files with 28 additions and 7 deletions
|
@ -230,3 +230,19 @@ if Image is not None:
|
|||
finally:
|
||||
del images.open
|
||||
self.assert_(FileWrapper._closed)
|
||||
|
||||
class InconsistentGetImageDimensionsBug(TestCase):
|
||||
"""
|
||||
Test that get_image_dimensions() works properly after various calls using a file handler (#11158)
|
||||
"""
|
||||
def test_multiple_calls(self):
|
||||
"""
|
||||
Multiple calls of get_image_dimensions() should return the same size.
|
||||
"""
|
||||
from django.core.files.images import ImageFile
|
||||
img_path = os.path.join(os.path.dirname(__file__), "test.png")
|
||||
image = ImageFile(open(img_path))
|
||||
image_pil = Image.open(img_path)
|
||||
size_1, size_2 = get_image_dimensions(image), get_image_dimensions(image)
|
||||
self.assertEqual(image_pil.size, size_1)
|
||||
self.assertEqual(size_1, size_2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue