New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot get exif data #6827
Comments
Could you attach your image? |
I tried many images, and I verified that there are exif info by other exif tools. |
If I run your code against https://github.com/python-pillow/Pillow/blob/main/Tests/images/exif.png, I get Unless you don't see that for exif.png, then there must be something specific about your image. |
You are right. I get data as you did. |
For JPG and MPO, we read information from the APP1 marker. Is your image in one of those formats, or something else? |
Ok, it is a JPG image. Somewhat confusingly, https://exiftool.org/TagNames/EXIF.html lists EXIF tags, and one of the groups listed is an ExifIFD. DateTimeOriginal is part of the ExifIFD. So if I run the following code with your image, import sys
from PIL import Image, ExifTags
if __name__ == '__main__':
image = Image.open(sys.argv[1])
exif_info = image.getexif()
for tag, value in exif_info.items():
print("Base:", ExifTags.TAGS.get(tag, "Unknown "+str(tag)), value)
for tag, value in exif_info.get_ifd(34665).items():
print("Exif:", ExifTags.TAGS.get(tag, "Unknown "+str(tag)), value) part of the output is
When the next version of Pillow is released in a few days with #6748, you can replace Alternatively, if you would prefer that Pillow should give you all of this information at once, we do still have import sys
from PIL import Image, ExifTags
if __name__ == '__main__':
image = Image.open(sys.argv[1])
exif_info = image._getexif()
exif_dict = {ExifTags.TAGS.get(tag): value for tag, value in exif_info.items()}
print(exif_dict) gives
|
Here is the output of a GitHub Actions job with a fresh install of Pillow in Ubuntu 22.04 with Python 3.10, to demonstrate that this should be working - https://github.com/radarhere/Pillow/actions/runs/3798463170/jobs/6460192381#step:7:12 What does this output? from PIL import Image
image = Image.open("/home/ubuntu/IMG_20031001_113300.jpg")
print(list(image.info.keys()))
print(image.applist) How did you install Pillow? It might sound weird, but have you tried uninstalling Pillow and re-installing it? If I put together a branch with some debugging statements to try and investigate this further, would you be willing to install that version of Pillow to see what happens? |
Ok, if you could run
That will install https://github.com/radarhere/Pillow/tree/6827_debug with the print statements in radarhere@2a9b9e2. Then call |
You're building from Pillow from source code now, so some dependencies are required. The minimal set of dependencies should be |
>>> from PIL import Image
>>> image = Image.open('/home/ubuntu/IMG_20031001_113300.jpg')
Hash: c817bfdb8a88f768b866df65f4796af4a6f7cf191798efbdec03fb77a846cf17
fp.tell(): 4 i: 0xFF 65504
Marker: APP0 Handler: <function APP at 0x7f341cfe7400>
APP 65504 s b'JFIF\x00\x01\x01\x00\x00\x01' fp.tell(): 20
fp.tell(): 22 i: 0xFF 65499
Marker: DQT Handler: <function DQT at 0x7f341cfe75b0>
fp.tell(): 91 i: 0xFF 65499
Marker: DQT Handler: <function DQT at 0x7f341cfe75b0>
fp.tell(): 160 i: 0xFF 65472
Marker: SOF0 Handler: <function SOF at 0x7f341cfe7520>
fp.tell(): 179 i: 0xFF 65476
Marker: DHT Handler: <function Skip at 0x7f341cf9d090>
fp.tell(): 212 i: 0xFF 65476
Marker: DHT Handler: <function Skip at 0x7f341cf9d090>
fp.tell(): 395 i: 0xFF 65476
Marker: DHT Handler: <function Skip at 0x7f341cf9d090>
fp.tell(): 428 i: 0xFF 65476
Marker: DHT Handler: <function Skip at 0x7f341cf9d090>
fp.tell(): 611 i: 0xFF 65498
Marker: SOS Handler: <function Skip at 0x7f341cf9d090>
>>> exif = image._getexif()
>>> print(exif)
None |
Thanks. When I run it with https://user-images.githubusercontent.com/25956878/209842976-c0dca8ee-81d2-4353-8987-a53e97fd89db.jpg, I get a hash of So I can see two possible actions at this point.
|
Great, thanks. I found the mistake that I made. I overwrite the image with new generated thumbnail, no wonder I failed to get the exif data. |
Pillow 9.4.0 has now been released. |
What did you do?
call getexif interface
What did you expect to happen?
return full exif information.
What actually happened?
No exif data, return empty dict. Actually exif_info is an empty dict.
What are your OS, Python and Pillow versions?
The text was updated successfully, but these errors were encountered: