5

I have the following Python script:

from PIL import Image
from PIL.ExifTags import TAGS

img = Image.open('/path/1.jpg')
info = img._getexif()
print info

Why is info returned as None, although that I made sure that img has been read?

Thanks.

Simplicity
  • 47,404
  • 98
  • 256
  • 385
  • I don't know anything about PIL, but be careful using methods prefixed with an underscore; they're intented to be protected/private/internal, and subject to change in unpredictable ways. If there's a public method to get what you're after, try using that instead. – Jim Stewart Oct 30 '17 at 19:11
  • Which version of Python are you using? From this link (although this could be outdated now): https://stackoverflow.com/questions/4764932/in-python-how-do-i-read-the-exif-data-for-an-image it seems PIL's _getexif() might not work in later version of Python. You might want to look at Pillow - a fork from PIL, compatible with Python 3. – CodeMonkey123 Oct 31 '17 at 11:19
  • @Ryry thanks for your kind reply. I'm using Python 2.7.6 – Simplicity Oct 31 '17 at 13:02

1 Answers1

3

I think the issue was because the image I was reading seemed not to have exif data in the first place, as opposed to the images taken using a mobile phone camera for instance, which the image I was reading apparently hasn't.

Simplicity
  • 47,404
  • 98
  • 256
  • 385