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).


StarGeek

Quote from: Andrei Korzhyts on October 14, 2019, 02:22:31 PM
1. All cameras record time zone in same format or formats may differ (e.g. +07:00, 0700...)?

The format is shown.  + or -, 2 digits for the hour offset, 2 digits for the minute offset.

Quote2. 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).

Any particular reason you can't use a + sign?  AFAIK, it's a valid character for Windows, Linux, and Mac.

And I don't understand what the filename has to do with where you save the timezone.  Do you mean using the tag to name the files?  If so, then it's easy to get it to your format.  If you set OffsetTimeOriginal to the correct timezone, then in your command to rename files, use this:
${OffsetTimeOriginal;s/://g;s/\+/f/;s/-/b/}
It will remove the colon : and change the plus sign + to f and the minus sign - to b.

Your rename command would end up something like this
exiftool -d %Y%m%d_%H%M%S "-filename<${DateTimeOriginal}_${OffsetTimeOriginal;s/://g;s/\+/f/;s/-/b/}_${Make}${Model}...

* 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

#16
QuoteThe format is shown.  + or -, 2 digits for the hour offset, 2 digits for the minute offset.

I understand that.  :)
I'm just not sure if all cameras adhere to same standard and time zone will be recorded same format.
I can't check all cameras, so I ask if anyone has encountered different formats of timezone in different cameras?
For example, different cameras record fractions of a second in different formats with different accuracy.

QuoteAny particular reason you can't use a + sign...

It is very long to explain, and it is very difficult for me to tell the details in English.
In short, I create a rule system for naming and storing photo files.
Almost ready prerelease, which for me then translate on English and I'll post an his on this forum for discuss, if someone wants.
Started writing about it here — https://exiftool.org/forum/index.php/topic,10299.0.html

Quote${OffsetTimeOriginal;s/://g;s/\+/f/;s/-/b/}

Yeah, I thought of that, too.
If I'm not the only one thinking that, it's probably a good option.
I'm not good at metadata design and don't even know what questions to ask, only know what I want to get at the end.

Jom

QuotePersonally, I add it to all the places...

Can you copy me this command?
I know how to replace the value for OffsetTimeOriginal, but I don't know how to append the time zone to other date/time tags.

StarGeek

DateTimeOriginal should automatically be set by the camera.  Set OffsetTimeOriginal manually.  Then use the SubSecDateTimeOriginal to copy to any other tag you might want to.

For example, after making sure the above two tags are set,
exiftool "-IPTC:DateCreated<SubSecDateTimeOriginal" "-XMP:DateTimeOriginal<SubSecDateTimeOriginal" "-XMP:DateCreated<SubSecDateTimeOriginal" "-IPTC:TimeCreated<SubSecDateTimeOriginal" "-GPS:GPSDateStamp<SubSecDateTimeOriginal" "-GPS:GPSTimeStamp<SubSecDateTimeOriginal" <DIR>

My actual command is much shorter because I use a Shortcut tag I defined, but the idea is the same.
* 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

While I was waiting for an answer, I created this command:

exiftool -progress: -progress -overwrite_original -r -OffsetTime=+03:00 -OffsetTimeOriginal=+03:00 -OffsetTimeDigitized=+03:00 *.cr2

Next I do so:

exiftool -progress: -progress -r -d "%Y/%Y%m%d/%Y%m%d_%H%M%S" "-FileName<D:\${DateTimeOriginal}_${OffsetTimeOriginal;s/\+/f/;s/-/b/;s/://}_${Model;s/ //g}_${InternalSerialNumber}_${FileName}" *.cr2

But you do differently.
Why? I didn't think everything through?

StarGeek

Quote from: Andrei Korzhyts on October 14, 2019, 07:37:30 PM
But you do differently.

Must be a problem in translation.  You're example is adding time zone to the filename, which should work as you want.  But your other question was
Quote from: Andrei Korzhyts on October 14, 2019, 05:24:58 PM
I don't know how to append the time zone to other date/time tags.

My answer was to show how to add the time zone to other date/time tags.  My example was not an attempt to add time zone to the filename.
* 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

Quoteexiftool -progress: -progress -overwrite_original -r -OffsetTime=+03:00 -OffsetTimeOriginal=+03:00 -OffsetTimeDigitized=+03:00 *.cr2

Quoteexiftool "-IPTC:DateCreated<SubSecDateTimeOriginal" "-XMP:DateTimeOriginal<SubSecDateTimeOriginal" "-XMP:DateCreated<SubSecDateTimeOriginal" "-IPTC:TimeCreated<SubSecDateTimeOriginal" "-GPS:GPSDateStamp<SubSecDateTimeOriginal" "-GPS:GPSTimeStamp<SubSecDateTimeOriginal" <DIR>

It seems we a bit about different things write. I understood.
You change the date/time content by supplementing it with a time zone, and I don't, I add the time zone to a separate tag?

Jom

QuoteMy answer was to show how to add the time zone to other date/time tags.

I understand, thanks.
You add a timezone not with a special command (e.g. using regular expressions), you add a timezone using an intermediate composite tag?

StarGeek

Quote from: Andrei Korzhyts on October 14, 2019, 07:57:13 PM
You add a timezone not with a special command (e.g. using regular expressions), you add a timezone using an intermediate composite tag?

That is correct.  It may take a bit longer as it takes two passes, but it is less prone to user error.
* 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


Phil Harvey

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

It is necessary that the config file returns true.  By convention, including this as the last statement in the file guarantees this.

- 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

QuoteIt is necessary that the config file returns true.  By convention, including this as the last statement in the file guarantees this.

I don't know Perl yet, but I've already found the answer.

https://www.google.ru/search?newwindow=1&source=hp&ei=jielXdz4NsWIrwStoqvoAQ&q=perl+1%3B&oq=perl+1%3B&gs_l=psy-ab.3..0l4j0i22i30l6.3054.5485..6414...0.0..0.212.650.6j0j1......0....1..gws-wiz.......0i10.6VHDGuFf-io&ved=0ahUKEwjc9_D2lJ3lAhVFxIsKHS3RCh0Q4dUDCAU&uact=5

Thanks for the answer anyway.