我想使用 Python 将 GPS 信息添加到文件夹中一堆 jpg 图像的元数据中。
到目前为止我想出的代码如下所示:
## Exectute the script in the folder containing the image files
import glob
import pandas as pd
from exif import Image
# Import reference Data with columns of interest
df = pd.read_csv('reference.csv', delimiter='\s+', quotechar="'")
latitude = pd.read_csv('reference.csv', delimiter='\s+', quotechar="'", usecols=[2])
longitude = pd.read_csv('reference.csv', delimiter='\s+', quotechar="'", usecols=[3])
# store image files from the working directory in a list
images = [f for f in glob.glob("*.jpg")]
image = Image('pano_000004_000000.jpg')
image.gps_latitude = (latitude.iloc[1])
image.gps_longitute = (longitude.iloc[1])
dir(image)
现在我尝试将信息写入一张图片(没有用)。以后我想执行脚本,把缺失的GPS信息批量写入所有图片对应的图片中。 我如何编辑我的代码,以便它从参考文件中获取 gps 信息并将其写入相应图像的元数据中?
感谢阅读!
尝试使用gpsphoto
from GPSPhoto import gpsphoto
photo = gpsphoto.GPSPhoto("image.jpg")
info = gpsphoto.GPSInfo((float('55.555555'),float('33.333333')),timeStamp='2022:01:11 11:11:11')
photo.modGPSData(info, "image_with_gps.jpg")