温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Python中怎么读取照片的GPS信息

发布时间:2021-07-05 15:05:41 来源:亿速云 阅读:191 作者:Leah 栏目:大数据

本篇文章为大家展示了Python中怎么读取照片的GPS信息,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

EXIF

  可交换图像文件常被简称为EXIF(Exchangeable image file format),是专门为数码相机的照片设定的,可以记录数码照片的属性信息和拍摄数据

注:

  EXIF信息不支持png,webp等图片格式

python通过exifread模块获得图片exif信息 

ExifRead

Python library to extract EXIF data from tiff and jpeg files.

安装

pip install exifread

读取GPS

import exifreadimport re
def  read():    GPS = {}    date = ''    f = open("E:\\python\\IMG_20200119_145630.jpg",'rb')    contents = exifread.process_file(f)    for key in contents:        if key == "GPS GPSLongitude":            print("经度 =", contents[key],contents['GPS GPSLatitudeRef'])        elif key =="GPS GPSLatitude":            print("纬度 =",contents[key],contents['GPS GPSLongitudeRef'])read()

运行

Python中怎么读取照片的GPS信息

读取更多信息

import exifreadimport re
def  read():    GPS = {}    date = ''    f = open("E:\\python\\IMG_20200119_145630.jpg",'rb')    contents = exifread.process_file(f)    for key in contents:        if key == "GPS GPSLongitude":            print("经度: ", contents[key],contents['GPS GPSLatitudeRef'])            print("纬度: ",contents['GPS GPSLatitude'],contents['GPS GPSLongitudeRef'])            print("高度基准: ",contents['GPS GPSAltitudeRef'])            print("海拔高度: ",contents['GPS GPSAltitude'])        if re.match('Image Make', key):            print('品牌信息: ' , contents[key])        if re.match('Image Model', key):            print('具体型号: ' , contents[key])        if re.match('Image DateTime', key):            print('拍摄时间: ' , contents[key])        if re.match('EXIF ExifImageWidth', key):            print('照片尺寸: ' , contents[key],'*',contents['EXIF ExifImageLength'])        if re.match('Image ImageDescription',key):            print('图像描述: ' , contents[key])read()

Python中怎么读取照片的GPS信息

如何防止信息被泄露

传图的时候不要用原图
在相机的设置里,将地理位置关掉
直接将GPS的权限关掉

上述内容就是Python中怎么读取照片的GPS信息,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI