Skip to content

Pillow fails to open small PNGs with "Decompressed Data Too Large" - PIL opens successfully #2445

@ccazabon

Description

@ccazabon

What did you do?

Calling Image.load() on a file containing a 230x230 8-bit RGB PNG image.

What did you expect to happen?

Image successfully opened.

What actually happened?

An exception "ValueError: Decompressed Data Too Large" is thrown. Interestingly, PIL 2.3.0 successfully opens the same images. The images appear fine and open successfully in other software as well.

Relevant portion of the stack trace is:

File '.../<application>.py', line 533 in thumbnail
  img = PIL.Image.open(filename)
File '.../Pillow-3.2.0-py2.7-linux-x86_64.egg/PIL/Image.py', line 2299 in open
  im = _open_core(fp, filename, prefix)
File '.../Pillow-3.2.0-py2.7-linux-x86_64.egg/PIL/Image.py', line 2289 in _open_core
  im = factory(fp, filename)
File '.../Pillow-3.2.0-py2.7-linux-x86_64.egg/PIL/ImageFile.py', line 97 in __init__
  self._open()
File '.../Pillow-3.2.0-py2.7-linux-x86_64.egg/PIL/PngImagePlugin.py', line 507 in _open
  s = self.png.call(cid, pos, length)
File '.../Pillow-3.2.0-py2.7-linux-x86_64.egg/PIL/PngImagePlugin.py', line 136 in call
  return getattr(self, "chunk_" + cid.decode('ascii'))(pos, length)
File '.../Pillow-3.2.0-py2.7-linux-x86_64.egg/PIL/PngImagePlugin.py', line 305 in chunk_iCCP
  icc_profile = _safe_zlib_decompress(s[i+2:])
File '.../Pillow-3.2.0-py2.7-linux-x86_64.egg/PIL/PngImagePlugin.py', line 90 in _safe_zlib_decompress
  raise ValueError("Decompressed Data Too Large")
ValueError: Decompressed Data Too Large

What versions of Pillow and Python are you using?

64-bit Python 2.7 on x86_64 Linux.

Problem occurs with both Pillow 3.2.0, and newest release Pillow 4.0.0.

Sample image demonstrating the problem attached.
pillow-decompressed-data-too-large

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions