Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to read the GPS information of photos in Python

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you how to read the GPS information of photos in Python, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

EXIF

Interchangeable image files, often referred to as EXIF (Exchangeable image file format), are specially set for photos of digital cameras and can record attribute information and shooting data of digital photos.

Note:

EXIF information does not support image formats such as png,webp.

Python obtains picture exif information through exifread module.

ExifRead

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

Installation

Pip install exifread

Read 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 ("longitude =", contents [key], contents [' GPS GPSLatitudeRef']) elif key = "GPS GPSLatitude": print ("latitude =" Contents [key], contents ['GPS GPSLongitudeRef']) read ()

Running

Read more information

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 ("longitude:", contents [key], contents [' GPS GPSLatitudeRef']) print ("Latitude:", contents ['GPS GPSLatitude'] Contents ['GPS GPSLongitudeRef']) print ("height benchmark:", contents [' GPS GPSAltitudeRef']) print ("altitude:", contents ['GPS GPSAltitude']) if re.match (' Image Make', key): print ('Brand Information:', contents [key]) if re.match ('Image Model' Key): print ('specific model:', contents [key]) if re.match ('Image DateTime', key): print (' shooting time:', contents [key]) if re.match ('EXIF ExifImageWidth', key): print (' photo size:', contents [key],'*', contents ['EXIF ExifImageLength']) if re.match (' Image ImageDescription') Key): print ('image description:', contents [key]) read ()

How to prevent information from being disclosed

Do not use the original picture when transmitting the picture.

In the camera settings, turn off the geographic location

Directly turn off the permission of GPS. The above content is how to read the GPS information of photos in Python. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report