TNThieding/exif

Unable to add metadata to .jpg image

Opened this issue · 0 comments

uasdev commented

Hello,

I am trying to add metadata to .jpg files. However, after adding the meta data, I do not see it in Windows (by rght clicking image and looking at properties, or even in the Windows photo viewer). Upon further inspection, I tried to view the output image with the metadata I wrote to it, but the img.has_exif returns False.

Here is my code:

from exif import Image

with open("P3821925_0000411.jpg", "rb+") as f:
    img = Image(f)
# Exif image attributes:
# https://exif.readthedocs.io/en/latest/api_reference.html#image-attributes
img.gps_altitude = 25
img.gps_longitude = 42.01
img.gps_latitude = -72.05
# Save to new file
with open("P3821925_0000411_withexif.jpg", "wb") as new_image_file:
    new_image_file.write(img.get_file())

I am using exif version 1.6.0 with Python 3.11.

Link to the test image is:
https://github.com/uasdev/data-sharing

Thanks in advance!