﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
19457	ImageField size detection fails for some files even when PIL could succeed	Stephen Burrows	Anton Baklanov	"Some PNG files can't have their size detected by django because the clever method of size detection Django employs (I suspect in order to be somewhat more efficient?) fails horribly in these cases.

{{{
>>> import Image
>>> with open('/path/to/file.png') as f:
...  im = Image.open(f)
... 
>>> im.size
(480, 362)
>>> from django.core.files.images import get_image_dimensions
>>> with open('/path/to/file.png') as f:
...  get_image_dimensions(f)
... 
Traceback (most recent call last):
  File ""<console>"", line 2, in <module>
  File ""django/core/files/images.py"", line 58, in get_image_dimensions
    p.feed(data)
  File ""PIL/ImageFile.py"", line 402, in feed
    im = Image.open(fp)
  File ""PIL/Image.py"", line 1965, in open
    return factory(fp, filename)
  File ""PIL/ImageFile.py"", line 91, in __init__
    self._open()
  File ""PIL/PngImagePlugin.py"", line 331, in _open
    s = self.png.call(cid, pos, len)
  File ""PIL/PngImagePlugin.py"", line 115, in call
    return getattr(self, ""chunk_"" + cid)(pos, len)
  File ""PIL/PngImagePlugin.py"", line 296, in chunk_zTXt
    self.im_info[k] = self.im_text[k] = zlib.decompress(v[1:])
error: Error -5 while decompressing data: incomplete or truncated stream
}}}"	Bug	closed	File uploads/storage	1.4	Normal	fixed	image	antonbaklanov@…	Accepted	1	0	0	0	0	0
