程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

python提取照片坐标信息

发布于2019-08-07 12:06     阅读(1278)     评论(0)     点赞(5)     收藏(2)


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['GPSInfo'][4][0][0]
                        E2 = ret['GPSInfo'][4][1][0]
                        E3 = ret['GPSInfo'][4][2][0]
                        E=int(E1)+int(E2)*(1.0/60)+int(E3)*(1.0/360000)
                        out.write(str(N)+','+str(E)+'\n')
        except:
            pass
out.close()
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33


所属网站分类: 技术文章 > 博客

作者:西红柿煎鸡蛋

链接:https://www.pythonheidong.com/blog/article/10621/739ee37e6452bb29d76e/

来源:python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

5 0
收藏该文
已收藏

评论内容:(最多支持255个字符)