修改jpg图像的经纬度

缺点是图片必须带有经纬度信息否者就会报错,仅限于在含有gps信息的jpg上修改图片。
import piexif
from PIL import Image
 
# Read Image
fname = 'Wide.JPG'
img = Image.open(fname)

exif_dict = piexif.load(img.info['exif'])
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:24  祥瑞哈哈哈  阅读(125)  评论(0编辑  收藏  举报