ExifTool > Bug Reports / Feature Requests

please allow users to get and set tags by ID instead of just by name

(1/5) > >>

dae65:
Dear Phil,

As a follow-up to the other thread, I've written a wrapper SetNewValueByID() method and a FindTagInfoByID function which together enable SetNewValue() to set tag values by ID, instead of just by name. The wrapper simply ensures that a group is provided, and that a new ByID option is true. In other words, these would be equivalent:


--- Code: ---$et->SetNewValue     ( '©alb', 'My Album', Group => 'ItemList', ByID => 1 );
$et->SetNewValueByID ( '©alb', 'My Album', Group => 'ItemList' );

--- End code ---

I was wondering if you'd be able to have a look at it (attached). This seems to work as far as the ItemList and UserData groups are concerned, and I suppose it will work for any other group where tag IDs are unique in a table. I understand a solution to some other tables isn't going to be as straightforward. Maybe issuing for the time being a warning against using it with such groups?

The rationale behind this is to allow users more easily to determine what underlying tags will actually be written to, or read from, a file. Where tag names are ambiguous in a single table (e.g., 'Title' in QuickTime ItemList), users will be able pick a particular tag ID (titl or ©nam?) if it matters which one will be used at the end. The other solution (here) works too, but I think this one will be seen as less complicated from a user's point of view.

I hope you like the idea. Please find a diff file attached. I tried to meddle as little as possible with your code. Image::ExifTool is a great tool. Thank you for the tremendous amount of work you have put into it.

Best.

Phil Harvey:
I don't like this solution because it doesn't work for the command line.  But something has to be done here so I will think about this.  I'm thinking along the lines of making a new group which is the tag ID, and allowing you to specify that group when writing.  This would work fine except that the tagID's don't follow the ExifTool convention for group names (/^[A-Z][-_A-Za-z0-9]+$/), but I think I can work around this, maybe by converting other characters to hex and adding a leading "ID_" or something to the group name.

- Phil

dae65:

--- Quote from: Phil Harvey on July 25, 2020, 06:49:22 AM ---I don't like this solution because it doesn't work for the command line.

--- End quote ---
Not yet... ;) This solely depends on how command-line arguments are parsed. Preferably, we could also add some --set-tag-by-id <ID> <VALUE> command-line action/option, and thereby preserve -TAG= as it currently is.


--- Quote from: Phil Harvey on July 25, 2020, 06:49:22 AM ---But something has to be done here so I will think about this.
--- End quote ---
Thanks. :) I really appreciate it.


--- Quote from: Phil Harvey on July 25, 2020, 06:49:22 AM ---I'm thinking along the lines of making a new group which is the tag ID, and allowing you to specify that group when writing.
--- End quote ---
I'm afraid tag IDs would thereby become ambiguous, just like tag names already are, across underlying tables: ©alb, for instance, appears under both udta and ilst atoms (or in both UserData and ItemList groups). Either such a new table would have to replicate that on yet another level, or users would be required to provide a group or subgroup, just as with our provisional SetNewValueByID above.

Honestly, I guess the idea I suggested above would be easier to implement, as it already makes use of the existing tables from Image::ExifTool::TagLookup, and of the existing machinery of SetNewValue. All we would need to do is write a few additional "byID" wrapper methods.


--- Quote from: Phil Harvey on July 25, 2020, 06:49:22 AM ---This would work fine except that the tagID's don't follow the ExifTool convention for group names (/^[A-Z][-_A-Za-z0-9]+$/), but I think I can work around this, maybe by converting other characters to hex and adding a leading "ID_" or something to the group name.

--- End quote ---
I respectfully think this is not a good idea. At the very least, this would duplicate tables. Moreover, I don't see the point of doing this, since we already have a run-time, non-hard-coded, way to lookup tags by ID.

Thanks a lot for your time, Phil.
Best.

Phil Harvey:

--- Quote from: dae65 on July 25, 2020, 09:11:53 AM ---Preferably, we could also add some --set-tag-by-id <ID> <VALUE> command-line action/option, and thereby preserve -TAG= as it currently is.
--- End quote ---

This has 2 problems.

1. A new option is required (and there are already too many of these).  But admittedly this isn't a big problem.

2. Tag ID's in general can not be represented in ASCII, so using them directly on the command line is problematic.

- Phil

dae65:
Right. So maybe, yes, we could use an alias in a group for an ID in the same group. Such an alias, I insist, would need to be really just an alias, and not a tag name in another group. Otherwise we might get ambiguous aliases, which would defeat the purpose.

Also, I'd like to suggest that aliases should be meant to be used only, or primarily, on the command line, and that the API should be able to work with IDs directly as such. While the command-line argument vector is being parsed, the API or the exiftool command-line application itself would translate aliases into IDs, and pass IDs to the relevant methods, not aliases, so that other applications using Image::ExifTool wouldn't need to deal with aliases if they already had the IDs.

Thank you.

Navigation

[0] Message Index

[#] Next page

Go to full version