From 3aa4b8165da23a2f094d0eeffacbda5484f4c1f6 Mon Sep 17 00:00:00 2001 From: Anton Baklanov Date: Thu, 13 Dec 2012 18:26:34 +0200 Subject: Fixed #19457 -- ImageField size detection failed for some files. This was caused by PIL raising a zlib truncated stream error since we fed the parser with chunks instead of the whole image. --- tests/regressiontests/file_storage/magic.png | Bin 0 -> 70445 bytes tests/regressiontests/file_storage/tests.py | 15 +++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 tests/regressiontests/file_storage/magic.png (limited to 'tests') diff --git a/tests/regressiontests/file_storage/magic.png b/tests/regressiontests/file_storage/magic.png new file mode 100644 index 0000000000..a06449f9e9 Binary files /dev/null and b/tests/regressiontests/file_storage/magic.png differ diff --git a/tests/regressiontests/file_storage/tests.py b/tests/regressiontests/file_storage/tests.py index b6d3e1ff0b..4872ce87b9 100644 --- a/tests/regressiontests/file_storage/tests.py +++ b/tests/regressiontests/file_storage/tests.py @@ -7,6 +7,7 @@ import shutil import sys import tempfile import time +import zlib from datetime import datetime, timedelta from io import BytesIO @@ -559,6 +560,20 @@ class InconsistentGetImageDimensionsBug(unittest.TestCase): self.assertEqual(image_pil.size, size_1) self.assertEqual(size_1, size_2) + @unittest.skipUnless(Image, "PIL not installed") + def test_bug_19457(self): + """ + Regression test for #19457 + get_image_dimensions fails on some pngs, while Image.size is working good on them + """ + img_path = os.path.join(os.path.dirname(upath(__file__)), "magic.png") + try: + size = get_image_dimensions(img_path) + except zlib.error: + self.fail("Exception raised from get_image_dimensions().") + self.assertEqual(size, Image.open(img_path).size) + + class ContentFileTestCase(unittest.TestCase): def setUp(self): -- cgit v1.3