I'm trying to extract information from my Image
. First, I did:
from PIL import Image
image = Image.open
('C:\Users\yujin\Desktop\유진 분량\1502635829917s')
The output was the information of my Image
. Next, I did:
exif_data = image._getexif()
import PIL.ExifTags
exif = {
PIL.ExifTags.TAGS[k]:v
for k, v in image._getexif().items()
if k in PIL.ExifTags.TAGS
}
print exif['GPSInfo']
Then I got this error:
AttributeError Traceback (most recent call last) <ipython-input-4-d491fd7796a9> in <module>() ----> 1 exif_data = image._getexif() 2 3 import PIL.ExifTags 4 exif = { 5 PIL.ExifTags.TAGS[k]:v
AttributeError: 'function' object has no attribute '_getexif'
I don't know where I did wrong.
Sorry for my ignorance about this site's rules at first. I didn't know how to format code on this page. My apologies!
I put this on one line:
image = Image.open('C:\Users\yujin\Desktop\유진 분량\1502635829917s')
Then I got a new error:
IOError Traceback <ipython-input-17-1d98beb4f253> in <module>() 1 from PIL import Image ----> 2 image = Image.open('C:\Users\yujin\Desktop\Happy\2017-06-06-12-24-45') C:\ProgramData\Anaconda2\lib\site-packages\PIL\Image.pyc in open(fp, mode) 2475 2476 if filename: -> 2477 fp = builtins.open(filename, "rb") 2478 exclusive_fp = True 2479
IOError: [Errno 22] invalid mode ('rb') or filename: 'C:\Users\yujin\Desktop\Happy\x817-06-06-12-24-45'
This has to be on one line:
image = Image.open('C:\Users\yujin\Desktop\x.JPG')
What's happening now is that image
is defined as Image.open
and you are simply evaluating ('C:\Users\yujin\Desktop\x.JPG')
on a different line, so you get back the string in Out[10]
.
Clearly, the open
function will not have the attribute _getexif
, so you get that AttributeError
.