纬度 Latitude , 相当于 垂直 y 轴 的坐标 , 纬度的取值范围 -90 度 ~ + 90 度 ;
西经 和 南纬 是负数 ;
Pillow
安装
1
pip install Pillow
使用
上源码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
from PIL import Image, ExifTags
defpillow_get_exif_data(image_path): image = Image.open(image_path) # 获取图片的exif信息 exif_data = image._getexif() if exif_data isnotNone: # 使用自定义的函数转换exif标签 exif_data = { ExifTags.TAGS[k]: v for k, v in exif_data.items() if k in ExifTags.TAGS } return exif_data
defpillow_get_exif_data(image_path): image = Image.open(image_path) # 获取图片的exif信息 exif_data = image._getexif() if exif_data isnotNone: # 使用自定义的函数转换exif标签 exif_data = { ExifTags.TAGS[k]: v for k, v in exif_data.items() if k in ExifTags.TAGS } return exif_data
defexifread_get_exif_data(image_path): f = open(image_path,'rb') contents = exifread.process_file(f) f.close() return contents
if __name__ == '__main__': image_path = 'demo.JPG'
times = 1000
start = time.time() for _ inrange(times): exif_data = pillow_get_exif_data(image_path) end = time.time() print(f'pillow_get_exif_data: {end - start}')
start = time.time() for _ inrange(times): exif_data2 = piexif_get_exif_data(image_path) end = time.time() print(f'piexif_get_exif_data: {end - start}')
start = time.time() for _ inrange(times): exifread_get_exif_data(image_path) end = time.time() print(f'exifread_get_exif_data: {end - start}')