#πŸ”’ Edit file metadata with Python

31 messages Β· Page 1 of 1 (latest)

true falcon
#

Hi Hi, I was googling this some but haven't had much luck. Is there a way to change the Tag or Comment property of a file/image using Python? I read something that said I could use Pillow and Piexif, but im not familiar with piexif.

ember perchBOT
#

@true falcon

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

true falcon
#

Any advice is much appreciated

hazy rose
#

you presumably want to modify the exif data

true falcon
hazy rose
#

timestamps, as in the file itself was created on your machine several years ago?

#

if the metadata inside them is the timestamp you're talking about, you can just leave that intact

true falcon
#

Well, I copied the files from an old pc, but they retained their creation date

hazy rose
#

i wouldn't be attached to the creation date of a file, but if you wanted to you could just not modify the original file

#

and create a completely new one

#

or you could modify the metadata of the file itself

true falcon
hazy rose
#

oh, why not just add the metadata as part of the importing step?

#

like instead of modifying the file, just doing it when you insert into the db

hazy rose
#

well, how are you inserting this info into a database?

#

just modify that flow to be the stage at which you identify who's in a photo

#

then in the database store that metadata separately

#

e.g. in a person_to_image join table

true falcon
hazy rose
#

instead of storing that information in the exif metadata

true falcon
#

Well my only issue with that is, during the import step I'm not sure how to determine what tag to set for each photo unless I base it off the folder name, but then some folder names are related to trips, some photos may have multiple people

true falcon
hazy rose
#

that's just how i'd represent the many-to-one relationship of people inside a photo

hazy rose
hazy rose
true falcon
ember perchBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.