Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: metadata extraction #12359

Merged
merged 1 commit into from
Sep 7, 2024
Merged

refactor: metadata extraction #12359

merged 1 commit into from
Sep 7, 2024

Conversation

jrasm91
Copy link
Contributor

@jrasm91 jrasm91 commented Sep 5, 2024

  • Add logging to help understand date and timezone decisions for an asset
  • Streamline where and how exif data is sourced and merged
  • Simplify where and how exif and asset fields are set and saved to the database
  • Cleaner code by always return ImmichTags and ReverseGeocodeResult from the repositories

Comment on lines +375 to 380
// make sure dates comes from sidecar
const sidecarDate = firstDateTime(sidecarTags as Tags, EXIF_DATE_TAGS);
if (sidecarDate) {
for (const tag of EXIF_DATE_TAGS) {
delete mediaTags[tag];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't seem desirable that it'll use a lower-priority date-time tag from the sidecar over a higher-priority one in the original.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is actually very much on purpose. We allow changing the date time in immich and we write that to a sidecar file. We always write DateTimeOriginal. Images with higher priority fields, like SubSecDateTimeOriginal would be impossible to overwrite.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, but there are also tags below DateTimeOriginal that would get used instead of it. It's confusing behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

An interesting option would be to write both DateTimeOriginal and a custom tag like ImmichDateTimeOriginal. That tag would be the highest priority during metadata extraction if it exists. Probably out of scope for this PR, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nah, I think tags are confusing enough and the point is to be interoperable. We could potentially only remove tags from the sidecar is we find DateTimeOriginal in the sidecar. At the moment the only tag with higher priority than that is the sub-second one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For me at least, if you have a reliable date time tag in the xmp file we should use that always. I agree that maybe we should potentially ignore the low quality ones like CreateDate though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I like that.

return null;
}) as Promise<ImmichTags | null>;
return {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure how to feel about this. An empty object implies that it read the file successfully and there was just nothing there. If there was an issue reading it (permissions, etc.), it's not the same as it having no metadata.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The confusing part is probably the service should catch and ignore the error, not the repository. We don't actually ever differentiate or do anything in the failure case anyways, so it doesn't matter much if it is here or in the service.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it'd be nicer for the empty object fallback to live in the service.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have a list of things I am working through with regards to the metadata service file. I can make a note to move the try/catch/suppression to the service and write some additional tests for those scenarios in another PR.

server/src/services/metadata.service.ts Outdated Show resolved Hide resolved
@jrasm91 jrasm91 merged commit a9caa40 into main Sep 7, 2024
35 checks passed
@jrasm91 jrasm91 deleted the refactor/metadata-extraction branch September 7, 2024 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants