Author Topic: Add custom user-defined tags  (Read 7347 times)

Newsky

  • Full Member
  • ***
  • Posts: 70
Add custom user-defined tags
« on: July 18, 2016, 07:53:24 AM »
I can not figure out how to add custom fields.
1. Save the code here: http://www.sno.phy.queensu.ca/~phil/exiftool/config.html  to file ExifTool_config_add_new_tags
2. Run with the following parameters: exiftool -config c:\ExifToolGUI\ExifTool_config_add_new_tags "d:\My documents\Desktop\2016-06-13 17-40-42.jpg" -k
New fields are added. What am I doing wrong? And how can it add a new field without config file but only with the help of the command line?
Sorry for my english. I use Google translator

Hayo Baan

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 1079
  • Professional Photographer & Software Developer
    • Hayo Baan – Photography
Re: Add custom user-defined tags
« Reply #1 on: July 18, 2016, 09:07:00 AM »
I'm not sure I follow what you are trying to do here. With your exiftool command you just show the new tags IF they exist in the file (or, in case of composite tags if all their input tags are available). You're not adding anything to the file. Also what is the -k doing on the command-line, that shouldn't be there (unless you are running this from the Windows GUI, but then all options should  be between brackets, have a look at http://www.sno.phy.queensu.ca/~phil/exiftool/#running for more info)

Also note that the config file you created is just a demo without really useful tags. You should edit it to match what you are looking for.

In the  demo file you can also find instructions on how to name it and where to put it so it will be found automatically by exiftool saving you from having to add -t config CONFIGFILE to your exiftool command.

Hope this helps,
Hayo
Hayo Baan – Photography
Web: www.hayobaan.nl

Newsky

  • Full Member
  • ***
  • Posts: 70
Re: Add custom user-defined tags
« Reply #2 on: July 18, 2016, 12:14:36 PM »
Thank you Hayo! Apparently I was not ready for such tasks. My knowledge of the program and the language is not enough  :-[
Sorry for my english. I use Google translator

Hayo Baan

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 1079
  • Professional Photographer & Software Developer
    • Hayo Baan – Photography
Re: Add custom user-defined tags
« Reply #3 on: July 18, 2016, 01:03:17 PM »
If you explain what you are trying to accomplish, I'm sure we should be able to help you :)
Hayo Baan – Photography
Web: www.hayobaan.nl

Newsky

  • Full Member
  • ***
  • Posts: 70
Re: Add custom user-defined tags
« Reply #4 on: July 19, 2016, 12:39:51 AM »
I want to add two custom fields: URL and text into EXIF or XMP  :)
Sorry for my english. I use Google translator

Hayo Baan

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 1079
  • Professional Photographer & Software Developer
    • Hayo Baan – Photography
Re: Add custom user-defined tags
« Reply #5 on: July 19, 2016, 02:30:31 AM »
OK, that doesn't sound too complicated. In fact, the following simple config file already does what you want:

Code: [Select]
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::XMP::xmp' => {
        # URL tag (simple string, no checking, we specify the name explicitly so it stays all uppercase)
        URL => { Name => 'URL' },
        # Text tag (can be specified in alternative languages)
        Text => { Writable => 'lang-alt' },
    },
);

1;

This config file adds two new XMP tags: URL and Text, both are a simple string (Text can be specified in multiple languages, if this is never necessary, leave out the Writable => 'lang-alt' part in the definition)

I chose to add the tags to the existing XMP-xmp name space, an alternative would be to create your own namespace too, but that is probably not necessary for you.

Note: in the XMP-xmp namespace there is already a tag named BaseURL, perhaps you can use that instead of the URL tag we just created? Also instead of Text, perhaps there is an alternative existing tag you can use.

Note: it is unlikely that other software will recognise/show your new tags!
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Add custom user-defined tags
« Reply #6 on: July 19, 2016, 06:08:05 AM »
And the command will be something like this:

exiftool -config "c:\your config file name" -xmp-xmp:url="some url" -xmp-xmp:text="some text" "d:\My documents\Desktop\2016-06-13 17-40-42.jpg"

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

Newsky

  • Full Member
  • ***
  • Posts: 70
Re: Add custom user-defined tags
« Reply #7 on: August 03, 2016, 06:11:39 PM »
Hayo, Phil, Thank you so much! Everything worked out! It's a miracle!

Quote
an alternative would be to create your own namespace too
How can I do that?
Quote
Text can be specified in multiple languages
For Cyrillic should look like value: Writable => 'lang-alt'?
Quote
Note: it is unlikely that other software will recognise/show your new tags!
This is the most important thing in my task!
Sorry for my english. I use Google translator

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Add custom user-defined tags
« Reply #8 on: August 03, 2016, 10:02:11 PM »
Quote
an alternative would be to create your own namespace too
How can I do that?

See the XMP-xxx example in the sample config file.

Quote
Quote
Text can be specified in multiple languages
For Cyrillic should look like value: Writable => 'lang-alt'?

Yes.  Put that in the tag definition of the config file. then see the XMP tag name documentation for details on how to use alternate-language tags.

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

Newsky

  • Full Member
  • ***
  • Posts: 70
Re: Add custom user-defined tags
« Reply #9 on: August 04, 2016, 01:41:11 AM »
Phil! You're just in time, "gave me a fishing rod" Now, having carefully studied the many things I began to file example.config absolutely clear and I understood the principle. Previously, without your specific help, I could not understand, if you previously sent to me just to study the documentation, I could not have done, and then many of your concrete examples, I learned a lot! Thank you very much!
Sorry for my english. I use Google translator

SampsonF

  • Jr. Member
  • **
  • Posts: 13
Re: Add custom user-defined tags
« Reply #10 on: February 28, 2018, 07:41:19 AM »
%Image::ExifTool::UserDefined = (
    # All EXIF tags are added to the Main table, and WriteGroup is used to
    # specify where the tag is written (default is ExifIFD if not specified):
    'Image::ExifTool::Exif::Main' => {
        # Example 1.  EXIF:NewEXIFTag
        0xd000 => {
            Name => 'MyModifiedDate',
            Writable => 'int16u',
            WriteGroup => 'IFD0',
        },
        # add more user-defined EXIF tags here...
    },
);
1; #end

I put the above into ~/.ExifTool_config and I tried to write it by:

exiftool -MyModifiedDate='1970:01:01 00:11:22" FILE

I got complaint for not an integer.

I changed int16u -> text.  Then I got "Sorry, Can't write text values on this platform"

What should be the right format defination for a Date field?

I want to create a custom Date field to store the FileModifyDate before I change the file further.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Add custom user-defined tags
« Reply #11 on: February 28, 2018, 11:00:50 AM »
Try changing 'int16u' to 'string'.

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

shiregator

  • Newbie
  • *
  • Posts: 8
Re: Add custom user-defined tags
« Reply #12 on: November 22, 2018, 07:16:54 PM »
Will any tag types work for .mp4 files?  I tried EXIF, but it does not work for .mp4.

T:\pics>"T:\pics\exiftool(-k) v11.20.exe" -ArchivedOrigFile="sdf" "F:\Media Bin\GOPR0439_archive.MP4"
    0 image files updated
    1 image files unchanged

T:\pics>
T:\pics>
T:\pics>"T:\pics\exiftool(-k) v11.20.exe" -ArchivedOrigFile="sdf" "F:\Media Bin\20180719_174709x.jpg"
    1 image files updated
T:\pics>

   
%Image::ExifTool::UserDefined = (
    # All EXIF tags are added to the Main table, and WriteGroup is used to
    # specify where the tag is written (default is ExifIFD if not specified):
    'Image::ExifTool::Exif::Main' => {
        # Example 1.  EXIF:ArchivedOrigFile
        0xd000 => {
            Name => 'ArchivedOrigFile',
            Writable => 'string',
            WriteGroup => 'IFD0',
        },
        # add more user-defined EXIF tags here...
    },
);

shiregator

  • Newbie
  • *
  • Posts: 8
Re: Add custom user-defined tags
« Reply #13 on: November 22, 2018, 07:30:30 PM »
I found the solution.  XMP will work.

%Image::ExifTool::UserDefined = (
    # All EXIF tags are added to the Main table, and WriteGroup is used to
    # specify where the tag is written (default is ExifIFD if not specified):
    # XMP tags may be added to existing namespaces:
    'Image::ExifTool::XMP::xmp' => {
        # Example 5.  XMP-xmp:ArchivedOrigFile
        ArchivedOrigFile => { Writable => 'lang-alt' },
        # add more user-defined XMP-xmp tags here...
    },
);

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2569
Re: Add custom user-defined tags
« Reply #14 on: November 22, 2018, 08:18:29 PM »
I tried EXIF, but it does not work for .mp4.

Exif (and IPTC) tags in a video file are non-standard.  I believe some cameras will write Exif data when they create video files, but it isn't really something you'll find elsewhere.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.