-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose ExifKey
from libexiv2
for easy interoperability
#147
Comments
Well. Most users don't care about tag numbers, so pyexiv2 never reads or writes them.
|
Well, thanks for looking into it, my proposal was a bit simpler: just provide a translation table... A made up example would be: img_exif = image.getexif()
exiv2_dict = {}
for k, v in img_exif.items():
tag = ExifKey.from_tag(k)
exiv2_dict[tag.key] = v Note: This example doesn't do any type check for the value - this would be a responsibility of the user. Where
This way there would be two ways for interoperbility: by number and by References: Using this approach would avoid the need to be able to use the number for writing, i's up to the programmer to do the mapping for writing... |
I tried calling ExifKey() of exiv2: Exiv2::ExifKey key = Exiv2::ExifKey(34665, "Image");
std::cout << key.key() << std::endl;
std::cout << key.familyName() << std::endl;
std::cout << key.groupName() << std::endl;
std::cout << key.tagName() << std::endl;
std::cout << key.tag() << std::endl; It outputs: Exif.Image.ExifTag
Exif
Image
ExifTag
34665 I noticed that exiv2 uses decimal for the tag number, while pillow uses hexadecimal, but that's easy to convert. However, here's the bad news. 0x0001 Exif.Canon.CameraSettings
0x0001 Exif.Nikon1.Version
0x0001 Exif.Samsung2.Version This is a paradox: now that you know the groupName, you should already know the full tag name as well. So you don't need to convert the tag number into the tag name. Alternatively, we can manually save all possible exif tags, and their corresponding tag numbers, as a Python dict. But this Python dict needs to be updated frequently so that it is synchronized with exiv2. |
I just released v2.15.0, which adds >>> img.read_exif_detail()
{
'Exif.Image.ImageDescription': {
'idx': 1,
'ifdName': 'IFD0',
'tagDesc': 'A character string giving the title of the image. It may be a comment such as "1988 company picnic" or the like. Two-bytes character codes cannot be used. When a 2-bytes code is necessary, the Exif Private tag <UserComment> is to be used.',
'tagLabel': 'Image Description',
'tagNumber': 270,
'typeName': 'Ascii',
'value': 'test-中文-'
},
'Exif.Image.Make': {
'idx': 2,
'ifdName': 'IFD0',
'tagDesc': 'The manufacturer of the recording equipment. This is the manufacturer of the DSC, scanner, video digitizer or other equipment that generated the image. When the field is left blank, it is treated as unknown.',
'tagLabel': 'Manufacturer',
'tagNumber': 271,
'typeName': 'Ascii',
'value': 'test-中文-'
},
... |
As far as I can see it's currently not possible to use Exif tag numbers directly. A use case would be better interoperability with other modules like pillow.
A solution could be the following:
ExifKey
to translate them to the strings needed by this APIlist
/dict
to feed them intopyexiv2
This way it would possible have a better interoperability with fine grained control (no need to copy all using a byte buffer).
The text was updated successfully, but these errors were encountered: