当前位置: 移动技术网 > IT编程>脚本编程>Python > Python-根据照片信息获取用户详细信息(微信发原图或泄露位置信息)

Python-根据照片信息获取用户详细信息(微信发原图或泄露位置信息)

2019年12月18日  | 移动技术网IT编程  | 我要评论

太太口服液官网,酒店婚宴菜谱,洁婷姐

前言

本文的文字及图片来源于网络,仅供学习、交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理。

作者: 蒙娜丽胖

ps:如有需要python学习资料的小伙伴可以加点击下方链接自行获取

前言

有媒体曝出,微信发原图或存在泄露位置信息的风险。 对此,腾讯微信团队微博12月1日发布声明称,朋友圈发送的照片都经过系统自动压缩,不带位置等信息,实在担心的话,可以p完图再发,如下图:

在这里插入图片描述

微信团队提到过exif,何为exif?

可交换图像文件格式(英语:exchangeable image file format,官方简称exif),是专门为数码相机的照片设定的,可以记录数码照片的属性信息和拍摄数据。

exif最初由日本电子工业发展协会在1996年制定,版本为1.0。1998年,升级到2.1,增加了对音频文件的支持。2002年3月,发表了2.2版。

python库

这里需要python的两个库,一个是读取exif信息的exifread;一个是根据经纬度获取详细地址信息的geopy;

安装如下:

pip3 install exifread
​
pip3 install geopy

 

python源码

 1 import exifread
 2 import json
 3 import urllib.request
 4 import sys
 5 from geopy.geocoders import nominatim
 6 ​
 7 # 获取照片的详细信息
 8 def get_img_infor_tup(photo):
 9     img_file = open(photo, 'rb')
10     image_map = exifread.process_file(img_file)
11 ​
12     try:
13         #图片的经度
14         img_longitude_ref = image_map["gps gpslongituderef"].printable
15         img_longitude = image_map["gps gpslongitude"].printable[1:-1].replace(" ","").replace("/",",").split(",")
16         img_longitude = float(img_longitude[0])+float(img_longitude[1])/60+float(img_longitude[2])/float(img_longitude[3])/3600
17         if img_longitude_ref != "e":
18             img_longitude = img_longitude * (-1)
19 ​
20         #图片的纬度
21         img_latitude_ref = image_map["gps gpslatituderef"].printable
22         img_latitude = image_map["gps gpslatitude"].printable[1:-1].replace(" ","").replace("/",",").split(",")
23         img_latitude = float(img_latitude[0])+float(img_latitude[1])/60+float(img_latitude[2])/float(img_latitude[3])/3600
24         if img_latitude_ref != "n":
25             img_latitude = img_latitude*(-1)
26 ​
27         #照片拍摄时间
28         img_create_date = image_map["exif datetimeoriginal"].printable
29 ​
30         img_file.close()
31 ​
32         # 返回经纬度元组
33         return img_longitude, img_latitude, img_create_date
34 ​
35     except exception as e:
36         print('error:图片中不包含gps信息')
37 ​
38 # 根据经纬度获取详细的信息
39 def get_detail_infor(lat, lon):
40     reverse_value = str(lat) + ', ' + str(lon)
41     geolocator = nominatim()
42     location = geolocator.reverse(reverse_value)
43 ​
44     print('照片的经纬度信息:')
45     print((location.latitude, location.longitude))
46 ​
47     print('照片的地址信息:')
48     print(location.address)
49     
50     print('照片的全部信息:')
51     print(location.raw)
52 ​
53 if __name__ == '__main__':
54     infor_tup = get_img_infor_tup('./image/img_2174.jpg')
55     get_detail_infor(infor_tup[1], infor_tup[0])

 


   

运行结果

1 照片的经纬度信息:
2 (31.2734692, 121.4653229)
3 ​
4 照片的地址信息:
5 appart jeje, 45, 柳营路, 卓悦局, 静安区, 上海市, 200072, china 中国
6 ​
7 照片的全部信息:
8 {'place_id': 245107137, 'licence': 'data © openstreetmap contributors, odbl 1.0. https://osm.org/copyright', 'osm_type': 'node', 'osm_id': 6066843985, 'lat': '31.2734692', 'lon': '121.4653229', 'display_name': 'appart jeje, 45, 柳营路, 卓悦局, 静安区, 上海市, 200072, china 中国', 'address': {'address29': 'appart jeje', 'house_number': '45', 'road': '柳营路', 'neighbourhood': '卓悦局', 'city': '静安区', 'county': '静安区', 'state': '上海市', 'postcode': '200072', 'country': 'china 中国', 'country_code': 'cn'}, 'boundingbox': ['31.2733692', '31.2735692', '121.4652229', '121.4654229']}

 

结束语

exif针对所以的原图照片,所以在发照片的时候如果不想个人信息被泄露,可以发压缩过得图片和ps过得图片,需要说明的一点是通过微信发照片是默认压缩的!

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网