What did you do?
I attempted to read the meta-data from one of the test images from Exiv2 ("ReaganSmallPng.png"). This file contains EXIF and IPTC meta-data stored under compressed "Raw profile type" tags, typical of ImageMagick (and possibly other software).
What did you expect to happen?
- The Image's info["exif"] contains the EXIF data, and getexif() returns an object containing some or all of the meta-data, or
- The Image's info["Raw profile type exif"] contains the EXIF data, which can be manually fed back into info["exif"]
What actually happened?
The Image's info["exif"] was empty, and getexif() returned no metadata. The "Raw profile type exif" was read, but was not suitable to be used as info["exif"]. (Attempting this produces a SyntaxError in the TiffImagePlugin, which I haven't investigated further.) I tried modifying PngStream.chunk_zTXt in "PngImagePlugin.py" to skip decoding the bytes as "latin-1", but I still got the same SyntaxError.
Found Exif tags: 0
Traceback (most recent call last):
File "pil_err.py", line 9, in <module>
exif = reagan.getexif()
File "/usr/lib64/python3.6/site-packages/PIL/PngImagePlugin.py", line 704, in getexif
return ImageFile.ImageFile.getexif(self)
File "/usr/lib64/python3.6/site-packages/PIL/Image.py", line 1275, in getexif
self._exif.load(self.info.get("exif"))
File "/usr/lib64/python3.6/site-packages/PIL/Image.py", line 3237, in load
self._info = TiffImagePlugin.ImageFileDirectory_v1(self.head)
File "/usr/lib64/python3.6/site-packages/PIL/TiffImagePlugin.py", line 900, in __init__
super().__init__(*args, **kwargs)
File "/usr/lib64/python3.6/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' 8526' not valid)
What are your OS, Python and Pillow versions?
- OS: Gentoo Base System release 2.6, Linux kernel 4.19.97-gentoo x86_64
- Python: Python 3.6.10
- Pillow: Pillow 6.2.2 (from Gentoo), Pillow 7.0.0 (from Gentoo)
import PIL.Image
reagan = PIL.Image.open("ReaganSmallPng.png")
exif = reagan.getexif()
print("Found Exif tags:", len(exif.keys()))
reagan.info["exif"] = reagan.info['Raw profile type exif'].encode('latin-1')
exif = reagan.getexif()
print("Found Exif tags:", len(exif.keys()))
Image causing the issue

Additional information
ImageMagick's PNG encoder:
https://github.com/ImageMagick/ImageMagick/blob/master/coders/png.c
ExifTool's guide to PNG Tags:
https://exiftool.org/TagNames/PNG.html
What did you do?
I attempted to read the meta-data from one of the test images from Exiv2 ("ReaganSmallPng.png"). This file contains EXIF and IPTC meta-data stored under compressed "Raw profile type" tags, typical of ImageMagick (and possibly other software).
What did you expect to happen?
What actually happened?
The Image's info["exif"] was empty, and getexif() returned no metadata. The "Raw profile type exif" was read, but was not suitable to be used as info["exif"]. (Attempting this produces a SyntaxError in the TiffImagePlugin, which I haven't investigated further.) I tried modifying PngStream.chunk_zTXt in "PngImagePlugin.py" to skip decoding the bytes as "latin-1", but I still got the same SyntaxError.
What are your OS, Python and Pillow versions?
Image causing the issue
Additional information
ImageMagick's PNG encoder:
https://github.com/ImageMagick/ImageMagick/blob/master/coders/png.c
ExifTool's guide to PNG Tags:
https://exiftool.org/TagNames/PNG.html