How can I edit a line of image metadata?

38 Views Asked by At

Ive tried to follow this guide, and ive got this code:

from exif import Image
from PIL.ExifTags import TAGS

with open(f"images/salt-palace.jpg", "rb") as salt_palace_file:
    salt_palace = Image(salt_palace_file)

    salt_palace.image_description = "The Salt Palace Hotel in Salt Lake City."
    salt_palace.copyright = "Copyright 2024 (Your name here)"

print(f"Description: {salt_palace.image_description}")
print(f"Copyright: {salt_palace.copyright}")
with open('images/salt-palace-updated.jpg', 'wb') as updated_salt_palace_file:
    updated_salt_palace_file.write(salt_palace.get_file())

I want the program to save the salt-palace-update.jpg with description metadata, and then once that works go and edit the metadata, but I get a corrupted salt-palace-updated.jpg file instead. I'm fairly new to coding, so I don't know why this is happening, I have all the files in the right place with the right names.

0

There are 0 best solutions below