python提取照片坐标信息的代码如下所示:
from PIL import Image
from PIL.ExifTags import TAGS
import os
output="Z://result.csv"
out=open(output,'a')
out.write('lat,lon\n')
fpath="Z://iphonephoto"
for item in os.walk(fpath):
ob=item[2]
for i in ob:
name=fpath+'/'+str(i)
ret={}
try:
img=Image.open(name)
if hasattr(img,'_getexif'):
exifinfo=img._getexif()
if exifinfo !=None:
for tag,value in exifinfo.items():
decoded=TAGS.get(tag,tag)
ret[decoded]=value
N1 = ret['GPSInfo'][2][0][0]
N2 = ret['GPSInfo'][2][1][0]
N3 = ret['GPSInfo'][2][2][0]
N=int(N1)+int(N2)*(1.0/60)+int(N3)*(1.0/360000)
E1 = ret[&