I'm trying to extract GPS coordinates from a JPG
image but I don't get much information with pillow
.
This is my 1st attempt:
from PIL import Image
from PIL.ExifTags import TAGS
my_img = Image.open("IMG_0547.jpg")
exif_data = my_img.getexif()
for tag_id in exif_data:
tag = TAGS.get(tag_id, tag_id)
data = exif_data.get(tag_id)
print(f"{tag:16}: {data}")
Output:
TileWidth : 512
TileLength : 512
GPSInfo : 1996
ResolutionUnit : 2
ExifOffset : 216
Make : Apple
Model : iPhone XS
Software : 13.6
Orientation : 1
DateTime : 2020:08:13 21:01:41
XResolution : 72.0
YResolution : 72.0
Download the image from here
I also tried using pyexiv2
but I get this error for only o line of code
metadata = pyexiv2.ImageMetadata('IMG_0547.jpg')
which makes no sense because ImageMetadata
is listed in the official documentation here
Traceback (most recent call last):
File "maps.py", line 17, in <module>
metadata = pyexiv2.ImageMetadata('IMG_0547.jpg')
AttributeError: module 'pyexiv2' has no attribute 'ImageMetadata'
Can someone please help me get the coordinates?