Strange behavior with ImageDataHash tag in user-defined Composite tag

Started by CWCorrea, February 25, 2024, 12:45:47 AM

Previous topic - Next topic

CWCorrea

Hello Phil.

While creating an user-defined Composite tag which uses the ImageDataHash tag, I have noticed a strange behavior: If the ImageDataHash is "Required", the Composite tag does not return any value (it does not show in ExifTool's output). If the ImageDataHash is "Desired", the Composite tag returns the expected value.

I'm defining the DateAndMD5 tag as follows:

        DateAndMD5 => {
            Require => {
                0 => 'FileModifyDate',
                1 => 'ImageDataHash',
            },

            ValueConv => q{
                my $date = $val[0];
                my $md5 = $val[1];
                $self->Options(DateFormat => "%Y%m%d_%H%M%S");
                $date = $self->ConvertDateTime($date);
                return "${date}_${md5}";
            },
        },

I'm running ExifTool as follows:

exiftool -s -G1 -FileModifyDate -ImageDataHash -DateAndMD5  IMG_6772.JPG

The DateAndMD5 tags is not shown:

[System]        FileModifyDate                  : 2023:03:21 11:43:12-05:00
[File]          ImageDataHash                   : ac9f7aae55217c8e2d75ec2b46642d76

Modifying the tag definition to use "Desire" as follows:

        DateAndMD5 => {
            Desire => {
                0 => 'FileModifyDate',
                1 => 'ImageDataHash',
            },

            ValueConv => q{
                my $date = $val[0];
                my $md5 = $val[1];
                $self->Options(DateFormat => "%Y%m%d_%H%M%S");
                $date = $self->ConvertDateTime($date);
                return "${date}_${md5}";
            },
        },

exiftool -s -G1 -FileModifyDate -ImageDataHash -DateAndMD5  IMG_6772.JPG

Gives the correct output:

[System]        FileModifyDate                  : 2023:03:21 11:43:12-05:00
[File]          ImageDataHash                   : ac9f7aae55217c8e2d75ec2b46642d76
[Composite]     DateAndMD5                      : 20230321_114312_ac9f7aae55217c8e2d75ec2b46642d76

This behavior does not affect me as I simply can use Desire instead of Require, but I wanted to report this strange behavior to you.

Regards,

Christian W.

PS. I'm running ExifTool 12.77 on macOS 12.6.3

StarGeek

Phil will have to look at this, but this is what I think might be happening.

ImageDataHash isn't generated unless the -API RequestAll option or it is explicitly called for in the command.  What might be happening is the check for Require is happening before the ImageDataHash is generated, so your tag fails because it doesn't exist. After it gets generated, it exists when your tag is processed, as Composite tags are created last.
* 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).

Phil Harvey

Interesting.  This doesn't work because ImageDataHash is generated after the Composite tags are built.  I'll look into changing this.

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

CWCorrea


Phil Harvey

I've looked into this, and will fix this for 12.78.

As well as ImageDataHash, the Validate and ProcessingTime and UserParam tags were also generated after building the Composite tags.  I've changed the order to generate all of these except ProcessingTime earlier so they will be available for the Composite tags.  I didn't move ProcessingTime because I want it to include the time taken to generate the Composite tags.

Thanks for pointing out this oversight.

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

StarGeek

Quote from: Phil Harvey on February 28, 2024, 09:03:21 AMProcessingTime

And there's a tag I haven't seen before.  And it's been there since 2014.

It's only been mentioned in three other posts, and the earliest was in 2021.
* 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).

Phil Harvey

:)  There are a number of hidden gems like this in the Extra tags that aren't documented anywhere else.

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

StarGeek

I've read the Extra Tags page many times in detail, so I've almost certainly seen it before. I've just never remembered it because it is so rarely mentioned.
* 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).