ExifTool Forum

ExifTool => Newbies => Topic started by: Retired on April 21, 2013, 08:05:17 AM

Title: Create Custom Tag
Post by: Retired on April 21, 2013, 08:05:17 AM
I am a pensioner and I am doing this here just for fun.
I am an absolute beginner.

I can’t figure out how to create a customized tag.
I am using VBA (Access) calling the exiftool.exe

The tag should be a string named “GoogleShortpath”

Reading the FAQ, I at first have created an .exifTool.config like this:

‘Image::ExifTool::IPTC::ApplicationRecord' => {
        240 => {
            Name => 'GoogleShortpath',
            Format => 'string[0,24]',
        },

In VBA I now tried this:
Public Function CreateTag_Userdefined(ByVal exiftag As String, ByVal Newvalue As String, Picname As String) As Boolean
lngHandle = Shell(CurrentProject.Path & "\exifTool.exe -k " & " -" & exiftag & "=" & Chr(34) & Newvalue & Chr(34) & " " & Chr(34) & Picname & Chr(34))

But this doesn’t work.
I only get a message that the tag doesn’t exist.
So, how to do it?
Any suggestions?
Pls. explain in plain words.

Regards
Juergen
Title: Re: Create Custom Tag
Post by: Phil Harvey on April 21, 2013, 08:38:45 AM
Hi Juergen,

I always recommend trying the exiftool from the command line first because you miss useful error messages if you run from within another application (unless you capture and display the stderr output).

If you do this, you will see a syntax error from your config file.  (Assuming that ExifTool finds the config file that is.)

Try this config file:

Code: [Select]
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::IPTC::ApplicationRecord' => {
        240 => {
            Name => 'GoogleShortpath',
            Format => 'string[0,24]',
        },
    },
);
1; #end

Also, be sure the config file name is ".ExifTool_config", and that it is in your home directory or the directory of the exiftool program.

- Phil
Title: Re: Create Custom Tag
Post by: Retired on April 21, 2013, 10:50:56 AM
Hi, Phil,
thanks for the quick answer.
At first I have renamed the config-file.
Had been my mistake.

Then I copied your code into the file.

[Select]
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::IPTC::ApplicationRecord' => {
        240 => {
            Name => 'GoogleShortpath',
            Format => 'string[0,24]',
        },
    },
);
1; #end

There is nothing more in that file.

Trying to execute with “Shell…”, I get the following errors:
Operator or semicolon missing before %Image::ExifTool::UserDefined at E:\TestExi
fPics\Memories_DB\.ExifTool_config line 2.
Ambiguous use of % resolved as operator % at E:\TestExifPics\Memories_DB\.ExifTo
ol_config line 2.
Can't modify modulus (%) in scalar assignment at E:\TestExifPics\Memories_DB\.Ex
ifTool_config line 9, near ");"
Warning: Tag 'GoogleShortcut' does not exist
Nothing to do.
-- press any key –

Quite sure, that my command line is wrong.
How should it look like?

Juergen
Title: Re: Create Custom Tag
Post by: StarGeek on April 21, 2013, 03:27:59 PM
[Select] should not be part of the config file.
Title: Re: Create Custom Tag
Post by: Retired on April 22, 2013, 01:07:23 PM
Tnx, I now have deleted “[Select]” in the config file

The command line now looks like that:
E:\>exiftool -k -GoogleShotcut="xyz" E:\Test.jpg"

The message I get:
Can't modify constant item in scalar assignment at E:\.ExifTool_config line 8, near ");"
Warning: Tag 'GoogleShotcut' does not exist
Nothing to do.
-- press any key --

Juergen
Title: Re: Create Custom Tag
Post by: Retired on April 22, 2013, 01:11:03 PM
O sorry,
The command line had been like this:
E:\exiftool -k -GoogleShotcut="xyz" “E:\Test.jpg"
Title: Re: Create Custom Tag
Post by: Phil Harvey on April 22, 2013, 01:30:11 PM
The warning makes it sound like one of the "=>" in the file is a "=" by mistake.

Can you attach your config file here so I can take a look?

- Phil
Title: Re: Create Custom Tag
Post by: StarGeek on April 22, 2013, 06:00:08 PM
O sorry,
The command line had been like this:
E:\exiftool -k -GoogleShotcut="xyz" “E:\Test.jpg"

While I don't think it's what's causing your problem in this case, make sure that you use regular quotes, not fancy quotes as you did to the left of the E here. 

Fancy “ ” vs regular " "
Title: Re: Create Custom Tag
Post by: Retired on April 23, 2013, 10:58:56 AM
At first thanks for your patience with me.

I have corrected the config file and now it looks like this:

%Image::ExifTool::UserDefined => (
    'Image::ExifTool::IPTC::ApplicationRecord' => {
        240 => {
            Name => 'GoogleShortpath',
            Format => 'string[0,24]',
        },
    },
);
1; #end

But trying to write a value I still get the message
Tag ‘GoogleShortpath’ does not exist.
Command:
(Exiftool –k –GoogleShortpath=xyz test.jpg)

So do I need to run a command beforehand to create the tag?
Title: Re: Create Custom Tag
Post by: Phil Harvey on April 23, 2013, 11:27:50 AM
We're cycling around here. The error you got indicates that the config file was not loaded properly.  Try loading it via the command line option to see if this works:

exiftool -config your_config_file_name.cfg -k -googleshortpath=xxx test.jpg

(note that the -config option must come first on the command line)

- Phil
Title: Re: Create Custom Tag
Post by: Retired on April 24, 2013, 07:45:08 AM
Hi Phil,

Tnx for the command line.
But it’s still the same.

E:\>exiftool -config test.cfg -k -Googleshortpath=xxx Test.jpg
Warning: Tag 'Googleshortpath' does not exist

As you can see, there are no other warnings or error messages.
Title: Re: Create Custom Tag
Post by: Phil Harvey on April 24, 2013, 08:07:06 AM
Try attaching the config file you are using and I'll see if I can duplicate the problem.

- Phil
Title: Re: Create Custom Tag
Post by: Retired on April 25, 2013, 07:50:47 AM
Tnx Phil,
attached you will find the config file
Title: Re: Create Custom Tag
Post by: Phil Harvey on April 25, 2013, 07:59:03 AM
OK.  With the config file you posted, I got this:

Code: [Select]
> exiftool -config test.cfg -k -Googleshortpath=xxx Test.jpg
Useless use of a variable in void context at test.cfg line 1.
Useless use of a constant (Image::ExifTool::IPTC::ApplicationRecord) in void context at test.cfg line 1.
Useless use of anonymous hash ({}) in void context at test.cfg line 1.
Warning: Tag 'Googleshortpath' does not exist
Nothing to do.

When I fixed the config file (changed the first "=>" back to "="), it works:

Code: [Select]
> exiftool -config test.cfg -k -Googleshortpath=xxx Test.jpg
    1 image files updated
> exiftool -config test.cfg -k -Googleshortpath Test.jpg
Googleshortpath                 : xxx

Attached is the fixed config file.

(btw, the -k is not necessary when running from the command line.)

- Phil
Title: Re: Create Custom Tag
Post by: Retired on May 16, 2013, 02:53:22 PM
Hallo Phil,
I wasn’t online for some days.
Now I saw your new config file.
With that file it all works like a charm.

Let me say “THANKS” again.
I never have seen a better support, especially if one takes in his mind that you are doing this in your leisure time.