Skip to content

getexif() crashes when reading empty EXIF data from a PNG file saved by RawTherapy 5.8 #4676

@RomanKosobrodov

Description

@RomanKosobrodov

What did you do?

Converted a RAW file to PNG using RawTherapy 5.8.
Opened the image file with Pillow and called getexif()

What did you expect to happen?

Since the file has no EXIF data, the expected output is None or an empty dictionary.
pyexiv2 returns an empty dictionary.

What actually happened?

Traceback (most recent call last):
  File "/home/roman/Projects/pillow-png-getexif/read_png_exif.py", line 8, in <module>
    exif = img.getexif()
  File "/home/roman/Projects/mikula/venv/lib/python3.8/site-packages/PIL/PngImagePlugin.py", line 951, in getexif
    self._exif.load(exif_info)
  File "/home/roman/Projects/mikula/venv/lib/python3.8/site-packages/PIL/Image.py", line 3271, in load
    self._info = TiffImagePlugin.ImageFileDirectory_v1(self.head)
  File "/home/roman/Projects/mikula/venv/lib/python3.8/site-packages/PIL/TiffImagePlugin.py", line 900, in __init__
    super().__init__(*args, **kwargs)
  File "/home/roman/Projects/mikula/venv/lib/python3.8/site-packages/PIL/TiffImagePlugin.py", line 466, in __init__
    raise SyntaxError("not a TIFF file (header %r not valid)" % ifh)
SyntaxError: not a TIFF file (header b'\x00\x00\x11\x00\x00\x01\x04\x00' not valid)

What are your OS, Python and Pillow versions?

  • OS: Ubuntu 20.04
  • Python: Python version 3.8.2 [GCC 9.3.0]
  • Pillow: 7.1.1
fn = "mug_small.png"
img = Image.open(fn)
exif = img.getexif()

The code and the test image are available on github.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions