ExifTool Forum

ExifTool => Newbies => Topic started by: Newsky on July 18, 2016, 07:53:24 AM

Title: Add custom user-defined tags
Post by: Newsky 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.exiftool.org/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?
Title: Re: Add custom user-defined tags
Post by: Hayo Baan 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.exiftool.org/index.html#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
Title: Re: Add custom user-defined tags
Post by: Newsky 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  :-[
Title: Re: Add custom user-defined tags
Post by: Hayo Baan 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 :)
Title: Re: Add custom user-defined tags
Post by: Newsky on July 19, 2016, 12:39:51 AM
I want to add two custom fields: URL and text into EXIF or XMP  :)
Title: Re: Add custom user-defined tags
Post by: Hayo Baan 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:

%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!
Title: Re: Add custom user-defined tags
Post by: Phil Harvey 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
Title: Re: Add custom user-defined tags
Post by: Newsky on August 03, 2016, 06:11:39 PM
Hayo, Phil, Thank you so much! Everything worked out! It's a miracle!

Quotean alternative would be to create your own namespace too
How can I do that?
QuoteText can be specified in multiple languages
For Cyrillic should look like value: Writable => 'lang-alt'?
QuoteNote: it is unlikely that other software will recognise/show your new tags!
This is the most important thing in my task!
Title: Re: Add custom user-defined tags
Post by: Phil Harvey on August 03, 2016, 10:02:11 PM
Quote from: Newsky on August 03, 2016, 06:11:39 PM
Quotean alternative would be to create your own namespace too
How can I do that?

See the XMP-xxx example in the sample config file (https://exiftool.org/config.html).

Quote
QuoteText 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 (https://exiftool.org/TagNames/XMP.html) for details on how to use alternate-language tags.

- Phil
Title: Re: Add custom user-defined tags
Post by: Newsky 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!
Title: Re: Add custom user-defined tags
Post by: SampsonF 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.
Title: Re: Add custom user-defined tags
Post by: Phil Harvey on February 28, 2018, 11:00:50 AM
Try changing 'int16u' to 'string'.

- Phil
Title: Re: Add custom user-defined tags
Post by: shiregator 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...
    },
);
Title: Re: Add custom user-defined tags
Post by: shiregator 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...
    },
);
Title: Re: Add custom user-defined tags
Post by: StarGeek on November 22, 2018, 08:18:29 PM
Quote from: shiregator on November 22, 2018, 07:16:54 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.