python获取照片EXIF信息
时间:2023-01-01 19:30:00
一、前言
目前好多照片都已经抹掉了设备信息、拍摄时间和GPS除此信息外,还可以获得其他信息的隐私信息。在文章的最后,将提供可以找到完整信息的图片作为参考。
二、准备
主要是用python
的ExifRead图书馆获取照片信息
三、实现代码
1 安装依赖包
pip install exifread
2 具体代码
# -*- coding: utf-8 -*- import exifread def read(): with open("001.jpg", 'rb') as f: tags = exifread.process_file(f) for tag in tags.keys(): if tag not in ('JPEGThumbnail', 'TIFFThumbnail', 'Filename', 'EXIF MakerNote'): print("%s:, %s" % (tag, tags[tag])) if __name__ == '__main__': read()
四、参数详解
1 程序运行后的结果
Image Make:, HUAWEI Image Model:, Che1-CL20 Image Orientation:, Horizontal (normal) Image XResolution:, 72 Image YResolution:, 72 Image ResolutionUnit:, Pixels/Inch Image YCbCrPositioning:, Centered Image ExifOffset:, 156 GPS GPSLatitudeRef:, N GPS GPSLatitude:, [36, 15, 241699/10000] GPS GPSLongitudeRef:, E GPS GPSLongitude:, [117, 6, 35211/2500]
GPS GPSAltitudeRef:, 0
GPS GPSAltitude:, 1501
GPS GPSTimeStamp:, [21, 27, 57]
GPS GPSProcessingMethod:, ASCII
GPS GPSDate:, 2016:05:16
Image GPSInfo:, 546
Thumbnail Compression:, JPEG (old-style)
Thumbnail XResolution:, 72
Thumbnail YResolution:, 72
Thumbnail ResolutionUnit:, Pixels/Inch
Thumbnail JPEGInterchangeFormat:, 858
Thumbnail JPEGInterchangeFormatLength:, 6885
EXIF ExposureTime:, 1/3099
EXIF FNumber:, 2
EXIF ISOSpeedRatings:, 100
EXIF ExifVersion:, 0220
EXIF DateTimeOriginal:, 2016:05:17 05:27:58
EXIF DateTimeDigitized:, 2002:12:08 12:00:00
EXIF ComponentsConfiguration:, YCbCr
EXIF ShutterSpeedValue:, 11597/1000
EXIF ApertureValue:, 2
EXIF Flash:, Flash did not fire, auto mode
EXIF FocalLength:, 379/100
EXIF FlashPixVersion:, 0100
EXIF ColorSpace:, sRGB
EXIF ExifImageWidth:, 4208
EXIF ExifImageLength:, 2368
Interoperability InteroperabilityIndex:, R98
Interoperability InteroperabilityVersion:, [48, 49, 48, 48]
EXIF InteroperabilityOffset:, 516
EXIF ExposureIndex:, 94
EXIF WhiteBalance:, Auto
EXIF FocalLengthIn35mmFilm:, 27
EXIF GainControl:, Low gain up
2 参数对比
如1所得到的结果非专业人员不太好理解,所以,我找到了一个解析的网站,大家可以对比判断结果。图虫EXIF查看器
五、测试样例
样例图片