ExifTool Forum

ExifTool => Developers => Topic started by: luc99 on April 19, 2018, 06:18:32 AM

Title: Tag is not defined (c++)
Post by: luc99 on April 19, 2018, 06:18:32 AM
Hello,

I have a tiff image which tag is not standardised. More specifically, I want to copy this tag to another tiff image. I get the following error :

Warning: Tag 'Unknown_0x0023' is not defined


My code is as follow (I just here try to set it to a random value):

   
    ExifTool *et = new ExifTool();
    et->SetNewValue("Unknown_0x0023","41");
    et->WriteInfo(argv[2],"-overwrite_original\n-f");
    int result = et->Complete();
    if (result <= 0) cerr << "Error executing exiftool!" << endl;


I've tried the option -f (force) but it doesn't work. Any idea what I should do ?

Thanks
Title: Re: Tag is not defined (c++)
Post by: Phil Harvey on April 19, 2018, 07:00:19 AM
You need to create a user-defined tag definition (https://exiftool.org/config.html) to be able to write an unknown tag.

- Phil
Title: Re: Tag is not defined (c++)
Post by: luc99 on April 19, 2018, 09:57:07 AM
Ok, thanks, but I am not sure of how to adapt this to C++. Any hint on how to use this with the c++ interface ?
Title: Re: Tag is not defined (c++)
Post by: Phil Harvey on April 19, 2018, 10:03:15 AM
This should work as long as the config file is named .Exiftool_config and located in your home directory or the same directory as exiftool (as mentioned in the sample config file I linked).

- Phil
Title: Re: Tag is not defined (c++)
Post by: luc99 on April 19, 2018, 10:51:06 AM
Great, it now works !

Follow up question :

I now have 2 tags named "Unknown_0x0023", with different values. How is it possible to have twice the same name ? Is it because these tags are not stored at the same location in memory ? The output looks like this :

Unknown 0x0023                  : 63
Unknown 0x0023                  : 41


I modified your config file to define my specific tag as follow :

        # Example 1.  EXIF:NewEXIFTag
        0x0023 => {
            Name => 'Unknown_0x0023',
            Writable => 'int16u',
            WriteGroup => 'IFD0',
        },


Not sure what these numbers mean : 0xd000, 0xd001, etc..
Title: Re: Tag is not defined (c++)
Post by: Phil Harvey on April 19, 2018, 10:53:54 AM
The numbers are the tag ID stored in the file.

Are they stored in the same location?  (ie. add the -G1 option when extracting)

If so, then we have a problem.

- Phil
Title: Re: Tag is not defined (c++)
Post by: luc99 on April 19, 2018, 11:40:36 AM
The two tags are stored in different groups, which means I guess the file is consistent :

[IFD0]          Unknown 0x0023                  : 41
[MakerUnknown]  Unknown 0x0023                  : 63


But then, how can I force my code to write over the tag "Unknown 0x0023 " in the group "MakerUnknown" ?
Title: Re: Tag is not defined (c++)
Post by: Phil Harvey on April 19, 2018, 11:46:59 AM
Adding the ability to write unknown maker notes would be very complicated.  Basically nothing but ExifTool will read this metadata anyway.  Are you sure you need to do this?

- Phil