Skip to content

Conversation

@aelkiss
Copy link
Member

@aelkiss aelkiss commented Sep 18, 2025

This ended up being a bit tricky to track down because the error didn't give a useful stack trace, and the culprit is buried in the rather long convert_tiff_to_jpeg2000 method.

This was indeed a one-line fix (6b1f116#diff-0d491008f8069f2e647a11563976e76d9a8fd71e522c3efbb3b9384b58b93ae6R175), but getting there was a bit tricky in terms of figuring out exactly what triggered the issue, creating a test fixture, and then actually finding the source of the problem.

It may be worth thinking a bit about what we do with ImageRemediate in the future – in particular if we want to make major changes to this in the future we should do some refactoring and unit testing there first.

6b1f116 is the commit with the actual changes. Some comments inline.

"copy_old_to_new" was checking that the field existed previously, but
not that it was non-empty. This doesn't cover every possible scenario,
and there are likely other cases of invalid metadata in RGB TIFFs that
we may need to handle in the future, but we can deal with it when it
comes up.
@aelkiss aelkiss requested a review from liseli September 18, 2025 19:13
ok($validate->succeeded());
};

it "remediates empty DateTime in a bitonal TIFF file" => sub {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test (with its associated fixture) passed without any changes to the ImageRemediate code, but I think it's worth keeping as a regression test.

defined $self->{oldFields}->{$oldFieldName} and
not defined $self->{newFields}->{$newFieldName}
defined $self->{oldFields}->{$oldFieldName}
and $self->{oldFields}->{$oldFieldName} ne ''
Copy link
Member Author

@aelkiss aelkiss Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method (copy_old_to_new) is called here:

$self->copy_old_to_new("IFD0:ModifyDate", "XMP-tiff:DateTime");
but ExifTool didn't like being given an empty value for the new field value. This guards against that particular possibility. It might help avoid certain other kinds of oddities related to copy_old_to_new but I don't know if we've run into that exactly.

Copy link

@liseli liseli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look good. I appreciate seeing the different tests that consider various scenarios for image validation.

@aelkiss aelkiss merged commit 886872a into main Sep 19, 2025
1 check passed
@aelkiss aelkiss deleted the ETT-571 branch September 19, 2025 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants