How do I create my own tag group?

Started by Jom, October 13, 2019, 09:40:49 PM

Previous topic - Next topic

Jom

Hello.
How do I create a "MyGroup" in metadata with tags "Tag1", "Tag2", "Tag3"...?
I couldn't understand it:
# XMP tags may be added to existing namespaces:
    'Image::ExifTool::XMP::xmp' => {
        # Example 5.  XMP-xmp:NewXMPxmpTag
        NewXMPxmpTag => { Groups => { 2 => 'Author' } },
        # add more user-defined XMP-xmp tags here...
    },

Phil Harvey

By "group", do you mean a new XMP namespace?

Just replace "xxx" everywhere in the example config file with "MyGroup", and change the names of the tags defined in the new Image::ExifTool::XMP::MyGroup table.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Jom

Quote from: Phil Harvey on October 13, 2019, 10:07:27 PM
By "group", do you mean a new XMP namespace?

No, I want it to be like this:

exiftool -s -g 20130618_174522.CR2
...
---- MyGroup ----
MyTag1      :value
MyTag2      :value
...

Jom


Phil Harvey

I don't think that you understand what you are asking.

The family 0 groups shown by the -g option represent the format of the metadata.  ExifTool understands many metadata formats (EXIF, XMP and IPTC for example), but doesn't allow you to create a new format of your own.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Jom

Yes, you're right, I don't understand the structure of the metadata internal device, and I'm trying to understand it.
My question was " reconnaissance by combat."

Quotebut doesn't allow you to create a new format of your own
It helped me understand a bit.

Quotefamily 0 groups
Where can I read about it? There are also other groups (1, 2, 3...)?

If I understand correctly, the best place for own tags is XMP?

Phil Harvey

Yes.  XMP is best for adding custom tags.

The ExifTool groups are listed here, and explained in more detail here.

The recognized XMP tags are all listed here.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Jom

I need to create my own tag to record the time zone, because my camera does not save it.
I'm trying to read https://exiftool.org/config.html and trying to create your own configuration file, but I can not do it yet.
Can I for example get lines of code for .ExifTool_config that add the OwnTagOfTimeZone tag?

I do it:
%Image::ExifTool::UserDefined = (
   'Image::ExifTool::XMP::xmp' => {
      NewXMPxmpTag  => { Groups => { 2 => 'OwnTagOfTimeZone' } },
   },
)

and get it:
Warning: Tag 'OwnTagOfTimeZone' is not defined
Nothing to do.


I something wrong or translated or understand. Needed example.

Phil Harvey

Try this:

%Image::ExifTool::UserDefined = (
   'Image::ExifTool::XMP::xmp' => {
      OwnTagOfTimeZone=> { Groups => { 2 => 'Time' } },
   },
);
1; #end
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Jom


StarGeek

Quote from: Andrei Korzhyts on October 14, 2019, 11:11:59 AM
1; #end — This is necessary?

The example Phil listed would be for a separate config file which you could call by using the -Config option.  If you want to add it to an already existing .exiftool_config file, you would have to clip part of it out depending upon what's already in your config file.

If you are using the example config file, you just need to replace the line
NewXMPxmpTag => { Groups => { 2 => 'Author' } },
with
OwnTagOfTimeZone=> { Groups => { 2 => 'Time' } },
because the sample config file already has the ExifTool::UserDefined and Image::ExifTool::XMP::xmp parts and you can't have duplicates of those parts.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

StarGeek

Quote from: Andrei Korzhyts on October 14, 2019, 10:14:44 AM
I need to create my own tag to record the time zone, because my camera does not save it.

Is there any reason you want to make your own tag rather than use already existing tags that can hold the time zone?

Most (all?) XMP time tags can hold the time zone as part of the date.  XMP:DateCreated is the XMP version of EXIF:DateTimeOriginal (which is where the camera will set the time) and can be set as 2019:10:14 12:00:00-07:00.  The IPTC tag for the time stamp when the image was created is split into date (IPTC:DateCreated, set to 2019:10:14) and time (IPTC:TimeCreated, set to 12:00:00-07:00) and the time part requires a time zone.  In EXIF, the time zone is held separate in the OffsetTimeOriginal tag.

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Jom

####  1  ####

QuoteThe example Phil listed would be for a separate config file which you could call by using the -Config option.  If you want to add it to an already existing .exiftool_config file, you would have to clip part of it out depending upon what's already in your config file.

I use my own .exiftool_config, in which is just my code and nothing else.
If I understand correctly, then my .exiftool_config should only contain this?

%Image::ExifTool::UserDefined = (
   'Image::ExifTool::XMP::xmp' => {
      OwnTagOfTimeZone=> { Groups => { 2 => 'Time' } },
   },
);


Without?

1; #end

####  2  ####

QuoteIs there any reason you want to make your own tag rather than use already existing tags that can hold the time zone?

I don't know, but I need to add the time zone manually, because  camera doesn't it.
I'm just looking for solutions to this problem.
I will use the time zone in the filename and it seems to me that it should be a separate line in the metadata.
Example of filename:

20190718_032000_?_CanonEOS5DMarkIV_ZA2561817_IMG_0024.cr2

...?... — time zone.

What would you do?

StarGeek

Quote from: Andrei Korzhyts on October 14, 2019, 01:24:05 PM
I use my own .exiftool_config, in which is just my code and nothing else.

If this is the only thing in your .exiftool_config file is this entry, then copy/paste it exactly as Phil listed it, including the last line.

QuoteI don't know, but I need to add the time zone manually, because  camera doesn't it.
...
What would you do?

Personally, I add it to all the places I describe above (and more) because my camera doesn't keep track of it.  But it does need to be added separately.  I usually add it manually to OffsetTimeOriginal (as -OffsetTimeOriginal=-07:00) and then copy SubSecDateTimeOriginal to all the other tags.  SubSecDateTimeOriginal is a composite tag which merges the DateTimeOriginal which is set by the camera and the OffsetTimeOriginal which I just added.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Jom

Thanks Phil.
Thanks StarGeek.


I have a few more questions.

1. All cameras record time zone in same format or formats may differ (e.g. +07:00, 0700...)?
2. I can't use + and : in filename, so I'd better create my own timezone tag? My format is only f0700, b0700 (f, b — forward, backward).