immich-app / immich

High performance self-hosted photo and video management solution.
https://immich.app
GNU Affero General Public License v3.0
39.28k stars 1.85k forks source link

[BUG] Image appears in wrong date on timeline but has correct date and time when inspecting metadata #5391

Open spmdgit opened 7 months ago

spmdgit commented 7 months ago

The bug

Thank you for developing this wonderful app! In anticipation of doing a CLI upload of a large library of 10k pictures downloaded from iCloud, I uploaded a few test images using the browser and came across a date / time issue that I don't see reported yet. An image with a timestamp from the evening posts in the timeline as having been taken on the following day even though the metadata listed in the image view is correct. I believe this is related to a timezone / UTC issue, and I tried to replicated this on the demo server, but when I uploaded the image there, it posts on the correct date but the metadata lists the incorrect time for the image.

You can see this demonstrated in the images below. Here are three images, the first one was actually taken the day before and the following two were taken on the dates listed. 1

You can see the correct time and date for each image on the metadata listed in the image view on the next three screenshots. 2 3 4

I believe that if the last image had been taken after 7pm, it would have been placed on the following date in the timeline similar to the way the first image was handled.

As mentioned above, the demo server doesn't replicate this exactly, but the metadata represented there isn't correct either (maybe because I have the TZ environment variable set to US/Central in my .env file and the demo server is using UTC?). Anyway, here's how it looks on the demo server:

5 6

The OS that Immich Server is running on

Ubuntu 22.04

Version of Immich Server

v1.88.2

Version of Immich Mobile App

v1.88.0

Platform with the issue

Your docker-compose.yml content

version: "3.8"

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    command: ["start.sh", "immich"]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    ports:
      - 2283:3001
    depends_on:
      - redis
      - database
      - typesense
    restart: always

  immich-microservices:
    container_name: immich_microservices
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    # extends:
    #   file: hwaccel.yml
    #   service: hwaccel
    command: ["start.sh", "microservices"]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    depends_on:
      - redis
      - database
      - typesense
    restart: always

  immich-machine-learning:
    container_name: immich_machine_learning
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    volumes:
      - model-cache:/cache
    env_file:
      - .env
    restart: always

  typesense:
    container_name: immich_typesense
    image: typesense/typesense:0.24.1@sha256:9bcff2b829f12074426ca044b56160ca9d777a0c488303469143dd9f8259d4dd
    environment:
      - TYPESENSE_API_KEY=${TYPESENSE_API_KEY}
      - TYPESENSE_DATA_DIR=/data
      # remove this to get debug messages
      - GLOG_minloglevel=1
    volumes:
      - tsdata:/data
    restart: always

  redis:
    container_name: immich_redis
    image: redis:6.2-alpine@sha256:70a7a5b641117670beae0d80658430853896b5ef269ccf00d1827427e3263fa3
    restart: always

  database:
    container_name: immich_postgres
    image: postgres:14-alpine@sha256:28407a9961e76f2d285dc6991e8e48893503cc3836a4755bbc2d40bcc272a441
    env_file:
      - .env
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
    volumes:
      - pgdata:/var/lib/postgresql/data
    restart: always

volumes:
  pgdata:
  model-cache:
  tsdata:

Your .env content

# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables

# The location where your uploaded files are stored
UPLOAD_LOCATION=/media/second/immich

# The Immich version to use. You can pin this to a specific version like "v1.71.0"
IMMICH_VERSION=release

# Connection secrets for postgres and typesense. You should change these to random passwords
TYPESENSE_API_KEY=
DB_PASSWORD=

#TIMEZONE
TZ="US/Central"

###################################################################################
# Log message level - [simple|verbose]
###################################################################################

LOG_LEVEL=simple

# The values below this line do not need to be changed
###################################################################################
DB_HOSTNAME=immich_postgres
DB_USERNAME=postgres
DB_DATABASE_NAME=immich

REDIS_HOSTNAME=immich_redis

Reproduction steps

1.Set TZ in .env file to proper timezone
2.Upload image that would be categorized as having a date on the next day if it was interpreted in UTC
3.Image should have the proper time and date in the metadata on the image view but will be placed in the incorrect date on the timeline
...

Additional information

I should say also that I refreshed the metadata for the miscategorized image, and it didn't change anything.

spmdgit commented 7 months ago

Update: I didn’t check the iOS app before to see if the behaviour was the same as the web interface, but I checked it this afternoon, and, to my surprise, the pictures are all listed in the correct location. CC87B208-4819-4DF6-B9D8-B3CCE5A72ECE 59898E52-DD2D-49BC-ADB9-59E9AD38CCB0

Not sure if that helps or creates more confusion.

Tyree commented 7 months ago

Mine is the opposite. Images shown on the correct date (Nov 18) on the web app, but on the Android app, it's spread out from Nov 4-18

davidrudlstorfer commented 7 months ago

I observe the same phenomenon as @Tyree. Assets appear correctly within the timeline on the web app but incorrectly in the iOS app.

Tyree commented 7 months ago

Here's an example of my issue. Took these screenshots on my phone today. Info on the photos is correct, but they show up on seemingly random dates in the Android app timeline. Android: Screenshot_20231202_130913 Web: Screenshot 2023-12-02 131258 This wasn't happening until maybe the last couple of updates. Not sure exactly when.

PancakeZik commented 7 months ago

Here's an example of my issue. Took these screenshots on my phone today. Info on the photos is correct, but they show up on seemingly random dates in the Android app timeline. Android: Screenshot_20231202_130913 Web: Screenshot 2023-12-02 131258 This wasn't happening until maybe the last couple of updates. Not sure exactly when.

I have something quite similar, and it's solved when I fully refresh the time line in the mobile app

lnagel commented 6 months ago

Hey,

I've been experiencing the same problem both in the web and mobile apps during the past days. This was triggered when I geotagged some photos externally and then re-synced in Immich. A lot of photos started appearing out of order.

I investigated and it seems that while the time bucket API correctly uses localDateTime then I have a feeling that web and mobile apps further group assets in each timeline bucket using fileCreatedAt.

The big problem with fileCreatedAt value is that it is taken from the Linux stat call field mtime - this is the file modification date, which gets updated whenever someone edits the file. There are tools of course to sync the EXIF datetime into filesystem modification time, but this breaks file syncing utilities such as SyncThing from detecting changes.

Code search links:

https://github.com/search?q=repo%3Aimmich-app%2Fimmich+fileCreatedAt+language%3ASvelte&type=code&l=Svelte

https://github.com/search?q=repo%3Aimmich-app%2Fimmich+fileCreatedAt++path%3A%2F%5Emobile%5C%2F%2F&type=code&p=1

russelltg commented 4 months ago

I have a similar issue--I uploaded a bunch of files with incorrect original datetimes, and then used the updateAssets API to fix them. When I click/tap on them, they have the correct date/time, but they are still in the old incorrect spot in the timeline. Repro's on web and mobile.

On mobile, rebuilding the timeline (refresh twice) does not help.

susovit commented 3 months ago

I have issues with my screenshots. I imported the Google photos and all the screenshots are shown as uploaded date. PS: Captured photos have proper date.

vladkosarev commented 3 months ago

Same issue here. Web app seems to have more stable dates but android app is all over the place including Fri, Dec 31, 2049 images which do have correct exif dates set and work fine in web app.

Tyree commented 3 months ago

Still wrong intermittently for me. I'll take some photos and one or two of them will end up listed under the following day. A restart of immich and then it's fine. Only does this on the android app. Web is usually good to go.

Tyree commented 2 weeks ago

Still same issue. Happens pretty much every time I take more photos with my phone. They'll initially show strewn over a few days since the last date photos were added. Later on, I'll look and the photos will appear on the correct day. Again, web seems correct immediately. This is just on the Android app.

alextran1502 commented 2 weeks ago

@Tyree which phone model are you using, and which version of the OS? Is there anything special set in the settings regarding gps data, location permissions for photos...etc?

Tyree commented 2 weeks ago

@Tyree which phone model are you using, and which version of the OS? Is there anything special set in the settings regarding gps data, location permissions for photos...etc?

I'm using a Samsung Galaxy S22 Ultra - Android 14 Versions of the app have changed since I initially noticed this issue, but currently on 1.106.3 build.143

As far as I know it's all stock as far as photo location settings on the phone. I haven't messed with it. I don't even know where to mess with that. :-D I'm glad to look and see if anything is wonky if you tell me where to find those settings.

Right now, my timeline is perfect. Matches the web. I'm not sure exactly what happens that corrects it. But initially it'll be like this (All of those photos were taken on June 23 within minutes, but as you can see, when they first are uploaded and shown in Immich, they are all over the place.): Screenshot_20240623_170503