python向jpg图片添加经纬度信息

import piexif
from PIL import Image
 
# Read Image
fname = 'Wide.JPG'
img = Image.open(fname)

exif_dict = {"GPS":{}}
exif_dict['GPS'][piexif.GPSIFD.GPSLongitude] = ((180, 1), (17, 1), (532029, 1))
exif_dict['GPS'][piexif.GPSIFD.GPSLatitude] = ((180, 1), (17, 1), (532029, 1))
exif_dict['GPS'][piexif.GPSIFD.GPSAltitude] = ((200,1))

# Save image with modified exif data
exif_bytes = piexif.dump(exif_dict)
img.save('1_copy.JPG', exif=exif_bytes)


posted @ 2023-11-16 20:31  祥瑞哈哈哈  阅读(271)  评论(0编辑  收藏  举报