Incorrect date shown
Immich is incorrectly showing the date of the photos. It is adding 8 hours on the date it was taken. How do I correctly set this up?


87 Replies
We are aware of the issue and we planned to fix it. Timing is one of the hardest things in Computer Science š
that's okay! I thought I missed something in the setup. thanks
Yep, apologize for the inconvenience, we will communicate with the users clearly when we have it fixed
Is it currently known why it manages to use wrong dates as same seems to happen to videos and images?
because of the timezone
Timezone of the container?
date is correct, just the timezone translation is incorrect
Is it a frontend issue or is the API itself returning the wrong date for the assets?
It is the exif extraction issue
since timezone not always include in exif
Oh, yeah i can see that being an issue. :D
We have a path to fix it but not having the resource to work on it yet
Google Photos also got a lot of time zone incorrectly š
time is a hard issue especially dealing with different device that register the exif, some use gps and if gps isn't available, you lose that piece of info
or photos with a camera without timezone info
Hmm, I believe that the date the photo was taken is always included in the photo itself, no?
So one could potentially add an failback to the exif extraction that's global to the immich instance which timezone to use.
Timestamp, yes
but timezone isn't always there
and some camera have timestamp as UTC
Yes, thus failback.
so you will need to know which timezone need to be translated to
yes that is the plan
Of course some camera does it differently.
Correct
A lot of the incorrects in my case are from a bulk upload from CLI. :(
We are planning to use this tool to fix https://photostructure.github.io/exiftool-vendored.js/
exiftool-vendored
Documentation for exiftool-vendored
if you have time/effort you can try to open a PR to help fix the issue
Is it the server/microservices containers that do the exif extraction?

Okay, I can see how easilly it can fail currently.
Okay, I'm working on trying to get the parsing better, but I'm little confused as to what decides this Postgres query?
what did you try?
exiftool is smart enough so that it will extract timezone from GPS coordinates automatically and that timezone is correct and was automatically parsed.
Currently I have done the following:
That hmm logger shows up as
Sun Jun 27 2021 10:36:02 GMT+0000 (Coordinated Universal Time)
which is correct.try
newExif.dateTimeOriginal = createdAt.toISOString();
Since const createdAt = new Date(exifData.DateTimeOriginal || exifData.CreateDate || new Date(asset.createdAt));
create the Date object
the database expects the stringI feel like it's failing in the else for timezone converting:
That else is probably one of the issues.
if the new library handle the timezone correctly, this block of code can be removed
That
newExif.dateTimeOriginal
should be a string, not Date.Correct, but you assign the
Date
object to it
through this line const createdAt = new Date(exifData.DateTimeOriginal || exifData.CreateDate || new Date(asset.createdAt));
I'm not sure if I'm following as
Type 'string' is not assignable to type 'Date'.
Please make sure to check the type correct for the value you assign to the variable
There is also the problem with thisline
const createdAt = new Date(exifData.DateTimeOriginal || exifData.CreateDate || new Date(asset.createdAt));
I believe the new Date()
takes in a string but you evaluate new Date(asset.createdAt)
at the third case which might throw an errorThat line wasn't changed as if those exifData.DateTimeOriginal nor exifData.CreateDate doesn't exist in the data, it probably should use the asset's creation date.
Maybe open a PR and we can help take a look at it, it would be better for us to checkout the branch and help you debug as well š
There: https://github.com/immich-app/immich/pull/1326/
The Postgres error seems to come from when it tries to save the exif data, which makes sense if it's not in the right format it expects.
@Alex Tran I figured out that it was complaining about modifyDate one.
But shouldn't this be accepted?
Yay! I got it working. :)
Thank you, I will take a look at the PR later and add some feedback
We should still save the created date back to the original asset, yes?
Created date is passed in from the client and might not match the actual date here. The asset shows up in the timeline based on asset.createdAt and they both need to be the same.
Are you thinking of the case when there's no exif data or am I missing something?
What do you mean?
I think you mean just to preserve:
Right?
If, for some reason the mobile app, cli, or other client sends the wrong created at date or if it's different from what exif returns the asset will show up in the wrong place in the timeline. It's not so much about if there is exif or not, it's about the date used in the timeline being potentially different than the created date extracted from exif.
Yes
Ah, yeah. I can see now what you mean.
Also could these be the result of my changes or something else?
Also why does the vercel code-coverage fail? I cannot see it so please: https://vercel.com/immich/immich-code-coverage/HSfdiaaDmXMh4kfSX4jF4mfuniTT
This looks like a runtime thing - the ml model hasn't been loaded yet when this code runs. Either that or there's an error loading the model.
I don't have access, but it runs the server tests and deploys the coverage report. Possibly code coverage dropped (although you mostly removed code? Lol). You can connect to the server container locally and run all the checks to make sure they're still passing.
Contributing | Immich
Contributions are welcome!
I think something needs to be done about the
libs/common/src/utils/time-utils.ts:1:19
as it's using the exifr lib too.You can substitute the new library to do the same thing, correct?
Should be able to yes, but I'm banging my head against the types as it's Maybe<String> :D
Gave it the same treatment and pushed my changes. :)
We both seem to be working too fast for our own good kinda with the PR. :D
Thank you for the PR, this is quality change š I forgot to attach the issue that this PR resolves so I have to go find it
š
I was just looking through the code, are we changing the behavior of exif when a file is missing the info?
Not really, it still records as much data as possible
Specifically, we used to throw an error when exif parsing failed, now we're going to create smart asset info regardless if it fails or not, ri ght?
Smart asset info are tags that coming from Machine Learning
sorry, I mean the asset exif record
So then yes
With this library we can add functionality to write EXIF to the file
OK, but just clarifying - we did not use to always create a exif record, but now we have decided to always make a record regardless if exif parsing failed or not?
Ah I believe so, it should have been this way from the start.
Why is
parseStringToNumber
async?I am fixing that part
How come exifData is only closed (
exiftool.end()
if the file has DateTimeOriginal
? It seems like it should be closed always
(in the time-utils)Also fixing this part
Small nits were missed it seems, but I'm also not sure if that end is even needed in time-utils anymore. š¤
It does work though as is.
Right, but is it causing memory leaks?
That's a very good question which I don't know.
Tested and didn't see memory leaked
Did you test parsing file without exif data?
Yes
I mean specifically for memory leaks
Nope, I tested with not closing the exif instance
Yeah, it looks like you aren't supposed to use the import from
exitfool-vendored.pl
, but if you use the exiftool
singleton you don't need to call end()
.Yes, and if you use it the other way, tests are not happy.
What exactly about the test is not happy?
Not finding vendored-exiftool despite it being there.
Probably jest config issue
Do you have an actual error message?
GitHub
Bug: jest and vendored-exiftool doesn't seem to like each other Ā· I...
Describe the bug For unknown reason, I'm getting the Vendored ExifTool does not exist error despite it existing at /usr/src/app/node_modules/exiftool-vendored.pl/bin/exiftool on Alpine. To ...
On a Pixel 7 Pro, I was also facing the images being marked with incorrect timestamps, although only the ones with location data.
This is fixed in the latest update, thanks! Had to delete and re-upload the images to trigger the exif extraction again. Is there no way to delete exif data for all images and run it again?
We are planning to add a job to rescan all EXIF
@Alex Tran We might want to add some logic to the exif parsing for not respecting the DateTimeOriginal if it's in the future, like
"DateTimeOriginal": "2033:07:21 14:31:35"
:D
Same goes for CreateDate, and modify date.What do you mean?
I mean if the exif data is incorrect in a way that the dates are 1-5+ years into the future, I don't think those should be respected but rather try to figure out if any of them are at all less than 1 year into the future.

Example exif data:
That check only check if it's completely out of whack which that one for example is not.
Tough case, and edge case
the user have to edit this then
It would be nice if there was the ability to edit it.
Sounds like the edit exif issue from github š
GitHub
[Feature]: Metadata Editor Ā· Issue #232 Ā· immich-app/immich
Feature detail Hello, A metadata editor could be very cool feature, with update of metadata directly on file For fixing date/time of files or gps coordinate etc ... Platform Web
Just about to ask if that's the one. :D