'Interpreting GPS info of exif data from many photos in python

The above code could extract coordinates from a specific photo, how can I make it able to extract data from every photo existing in the directory?

from GPSPhoto import gpsphoto
data= gpsphoto.getGPSData('IMG_1.JPG')
print(data['Latitude'], data['Longitude'])


Solution 1:[1]

Hope this helps

from GPSPhoto import gpsphoto
import os
path = "C:/Users/pythonproject" #path to image folder
for i in os.listdir(path):
  data = gpsphoto.getGPSData(os.path.join(path,i))
  print(i,data['Latitude'], data['Longitude'])

Make sure all your paths have "/" in them. You may have put at "" in a path without realizing it. so e.x "C:/Windows" instead of "C:\Windows"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1