python图片修改过、有原图、怎么得到改动的地方_微信发照片原图会泄露行踪?手把手教会你如何用 Python 通过图片获取用户信息!...
原標題:微信發照片原圖會泄露行蹤?手把手教會你如何用 Python 通過圖片獲取用戶信息!
前言
有媒體曝出,微信發原圖或存在泄露位置信息的風險。
對此,騰訊微信團隊微博 12 月 1 日發布聲明稱,朋友圈發送的照片都經過系統自動壓縮,不帶位置等信息,實在擔心的話,可以 P 完圖再發,如下圖:
微信團隊提到過 Exif,何為Exif?
可交換圖像文件格式(英語:Exchangeable image file format,官方簡稱Exif),是專門為數碼相機的照片設定的,可以記錄數碼照片的屬性信息和拍攝數據。
Exif 最初由日本電子工業發展協會在 1996 年制定,版本為 1.0。1998年,升級到 2.1,增加了對音頻文件的支持。2002 年 3 月,發表了 2.2 版。
👉詳細請見百度百科《Exif》
Python 庫
這里需要 Python 的兩個庫,一個是讀取 Exif 信息的 exifread;一個是根據經緯度獲取詳細地址信息的 geopy;
安裝如下:
pip3 installexifread
pip3 installgeopy
Python 源碼
importexifread
importjson
importurllib.request
importsys
fromgeopy.geocoders importNominatim
# 獲取照片的詳細信息
defget_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
ifimg_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
ifimg_latitude_ref != "N":
img_latitude = img_latitude*( -1)
#照片拍攝時間
img_create_date = image_map[ "EXIF DateTimeOriginal"].printable
img_file.close
# 返回經緯度元組
returnimg_longitude, img_latitude, img_create_date
exceptException ase:
print( 'ERROR:圖片中不包含Gps信息')
# 根據經緯度獲取詳細的信息
defget_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。
想在命令行下高效管理百度網盤嗎?或許你應該用下這款神器!返回搜狐,查看更多
責任編輯:
總結
以上是生活随笔為你收集整理的python图片修改过、有原图、怎么得到改动的地方_微信发照片原图会泄露行踪?手把手教会你如何用 Python 通过图片获取用户信息!...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: css 和常用快捷键
- 下一篇: 微信小程序,ios上日期转时间戳出现的问