Add custom user-defined tags

Started by Newsky, July 18, 2016, 07:53:24 AM

Previous topic - Next topic

Newsky

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?
Sorry for my english. I use Google translator

Hayo Baan

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
Hayo Baan – Photography
Web: www.hayobaan.nl

Newsky

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

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

I want to add two custom fields: URL and text into EXIF or XMP  :)
Sorry for my english. I use Google translator

Hayo Baan

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!
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Newsky

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!
Sorry for my english. I use Google translator

Phil Harvey

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.

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 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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Newsky

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

%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

Try changing 'int16u' to 'string'.

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

shiregator

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

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

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