微信发照片原图会泄露行踪?手把手教会你如何用 Python 通过图片获取用户信息!...

公众号关注 「奇妙的 Linux 世界」

设为「星标」,每天带你玩转 Linux !




前言

有媒体曝出,微信发原图或存在泄露位置信息的风险。

对此,腾讯微信团队微博 12 月 1 日发布声明称,朋友圈发送的照片都经过系统自动压缩,不带位置等信息,实在担心的话,可以 P 完图再发,如下图:

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

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

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

????详细请见百度百科《Exif》 

https://baike.baidu.com/item/Exif/422825?fr=aladdin

Python 库

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

安装如下:

pip3 install exifread
 
pip3 install geopy

Python 源码

import exifread
import json
import urllib.request
import sys
from geopy.geocoders import Nominatim
 
# 获取照片的详细信息
def get_img_infor_tup(photo):
    img_file = open(photo, 'rb')
    image_map = exifread.process_file(img_file)
 
    try:
        #图片的经度
        img_longitude_ref = image_map["GPS GPSLongitudeRef"].printable
        img_longitude = image_map["GPS GPSLongitude"].printable[1:-1].replace(" ","").replace("/",",").split(",")
        img_longitude = float(img_longitude[0])+float(img_longitude[1])/60+float(img_longitude[2])/float(img_longitude[3])/3600
        if img_longitude_ref != "E":
            img_longitude = img_longitude * (-1)
 
        #图片的纬度
        img_latitude_ref = image_map["GPS GPSLatitudeRef"].printable
        img_latitude = image_map["GPS GPSLatitude"].printable[1:-1].replace(" ","").replace("/",",").split(",")
        img_latitude = float(img_latitude[0])+float(img_latitude[1])/60+float(img_latitude[2])/float(img_latitude[3])/3600
        if img_latitude_ref != "N":
            img_latitude = img_latitude*(-1)
 
        #照片拍摄时间
        img_create_date = image_map["EXIF DateTimeOriginal"].printable
 
        img_file.close()
 
        # 返回经纬度元组
        return img_longitude, img_latitude, img_create_date
 
    except Exception as e:
        print('ERROR:图片中不包含Gps信息')
 
# 根据经纬度获取详细的信息
def get_detail_infor(lat, lon):
    reverse_value = str(lat) + ', ' + str(lon)
    geolocator = Nominatim()
    location = geolocator.reverse(reverse_value)
 
    print('照片的经纬度信息:')
    print((location.latitude, location.longitude))
 
    print('照片的地址信息:')
    print(location.address)
    
    print('照片的全部信息:')
    print(location.raw)
 
if __name__ == '__main__':
    infor_tup = get_img_infor_tup('./image/IMG_2174.JPG')
    get_detail_infor(infor_tup[1], infor_tup[0])

运行结果

照片的经纬度信息:
(31.2734692, 121.4653229)
 
照片的地址信息:
Appart Jeje, 45, 柳营路, 卓悦局, 静安区, 上海市, 200072, China 中国
 
照片的全部信息:
{'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 过得图片,需要说明的一点是通过微信发照片是默认压缩的!

本文转载自:「Python 空间」,原文:https://url.cn/5sRkdxQ,版权归原作者所有。欢迎投稿,投稿邮箱: editor@hi-linux.com 。

你可能还喜欢

点击下方图片即可阅读

想在命令行下高效管理百度网盘吗?或许你应该用下这款神器!

点击上方图片,打开小程序,加入「玩转 Linux」圈子

更多有趣的互联网新鲜事,关注「奇妙的互联网」视频号全了解!

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值