I've been using Piexif to add tags to Jpeg images and that has been going fine. Now I wanted to read the tags an image has and I'm running into a problem. I gave an image the tags (Tag1, Tag2, Tag3) and using this code I'm supposed to be able to read those keywords:
exif_dict = piexif.load(path)
keywords = exif_dict["0th"][piexif.ImageIFD.XPKeywords]
What it returns is this:
(255, 254, 84, 0, 97, 0, 103, 0, 49, 0, 59, 0, 84, 0, 97, 0, 103, 0, 50, 0, 59, 0, 84, 0, 97, 0, 103, 0, 51, 0)
I understand that (84, 0, 97, 0, 103) stands for the word Tag, but I have no idea what kind of encoding this is.
Does someone happen to know what encoding Piexif uses or just recognizes it in general?
Might've been overthinking it. We can simply use something like this to return the numbers to ASCII characters.
tags = ""
for num in exif_dict["0th"][piexif.ImageIFD.XPKeywords]:
tags += chr(num)