immich-app / immich

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

[BUG] Missing thumbnails for Olympus ORF files #3995

Closed zhelyan closed 9 months ago

zhelyan commented 1 year ago

The bug

Olympus ORF files are not displayed in the gallery:

Screenshot 2023-09-06 at 09 16 08

The OS that Immich Server is running on

PRETTY_NAME="Debian GNU/Linux 11 (bullseye)" NAME="Debian GNU/Linux" VERSION_ID="11" VERSION="11 (bullseye)"

Version of Immich Server

v1.77.0

Version of Immich Mobile App

v1.77.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
    env_file:
      - .env
    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
    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

  immich-web:
    container_name: immich_web
    image: ghcr.io/immich-app/immich-web:${IMMICH_VERSION:-release}
    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

  immich-proxy:
    container_name: immich_proxy
    image: ghcr.io/immich-app/immich-proxy:${IMMICH_VERSION:-release}
    environment:
      # Make sure these values get passed through from the env file
      - IMMICH_SERVER_URL
      - IMMICH_WEB_URL
    ports:
      - 2283:8080
    depends_on:
      - immich-server
      - immich-web
    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=/mnt/nas/photos/immich
BACKUP_LOCATION=/mnt/nas/photos/immich/backups
# 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=xxxxxxxxx
DB_PASSWORD=xxxxxxxx

# 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. Upload https://raw.pixls.us/getfile.php/1432/nice/Olympus%20-%20XZ-2%20-%2012bit%20(4:3).orf
2. Refresh the UI
3. Scroll down to find the file ( to 16 Jul 2016 )
4. The thumbnail is broken
...

Additional information

Error logs when refreshing the thumbnail:

immich_microservices     | [Nest] 8  - 09/06/2023, 8:14:41 AM    WARN [MediaRepository] Could not determine colorspace of image, defaulting to p3 profile
immich_microservices     | [Nest] 8  - 09/06/2023, 8:14:41 AM   ERROR [JobService] Unable to run job handler: Error: Input file contains unsupported image format
immich_microservices     | [Nest] 8  - 09/06/2023, 8:14:41 AM   ERROR [JobService] Error: Input file contains unsupported image format
immich_microservices     | [Nest] 8  - 09/06/2023, 8:14:41 AM   ERROR [JobService] Object:
immich_microservices     | {
immich_microservices     |   "id": "e677c493-d5a6-4795-a8f0-22884849a5a6"
immich_microservices     | }
immich_microservices     |
immich_microservices     |
msrn commented 11 months ago

Also experiencing this issue. Tried it with the sample file above and got same results

[Nest] 995  - 10/15/2023, 1:14:24 PM   ERROR [JobService] Unable to run job handler (thumbnailGeneration/generate-jpeg-thumbnail): Error: Input file contains unsupported image format
[Nest] 995  - 10/15/2023, 1:14:24 PM   ERROR [JobService] Error: Input file contains unsupported image format
[Nest] 995  - 10/15/2023, 1:14:24 PM   ERROR [JobService] Object:
{
  "id": "f24ed36d-00e1-4e52-b9c2-24cfe35d7ed2",
  "source": "upload"
}
lyonzy commented 10 months ago

I went down the rabbit hole a bit on this. Immich uses Sharp for thumbnail rendering (alongside I'm sure much else) - command is here:

https://github.com/immich-app/immich/blob/main/server/src/infra/repositories/media.repository.ts#L28

Sharp uses libvips under the covers, and for raws like ORF libvips largely delegates to ImageMagick/GraphicsMagick.

Using the vips CLI (vips.exe copy .\P9170122.ORF .\P9170122.jpg) I got the same error trying to convert an ORF to a JPG (VipsForeignLoad: ".\P9170122.ORF" is not a known file format). Explicitly trying to use ImageMagick using vips magickload resulted in it not being able to find a ppm file which I assume is because ImageMagick isn't converting ORF->PPM.

So I have two mysteries - why libvips is saying it's not a known file format, and why ImageMagick isn't decoding ORFs. I'm hoping it might be as simple as putting a newer libmagick binary in.

There's also libraw in use, which is possibly how we're getting the metadata - it's possible that could also be used to make thumbnails (although it'd be simpler to have Sharp do it).

Another different idea might be to extract the embedded preview with something like this (might even save some compute power): https://www.npmjs.com/package/raw-preview

jrasm91 commented 10 months ago

this doesn't work - vips copy input.orf output.jpg this does work - vips magickload input.orf output.jpg

For some reason it is not using this loader. I'm not sure which loader it is using, but it is not picking this one, which does work fine. So it is less about using a newer libmagick binary and more about vips just not picking a loader that works.

lyonzy commented 10 months ago

You did better than I did - maybe my copy of vips/libmagick was broken. Sounds like you're right, the only mystery is why it's not falling back to magick.

jrasm91 commented 10 months ago

I'm testing directly on the immich-microservices container

lyonzy commented 10 months ago

Yeah it eventually worked for me in an Alpine container (I was testing on a Debian machine and then in a Ubuntu container) - maybe I'm affected by the same bug they mentioned in their dockerfile.

hiveai commented 9 months ago

Here is another file that has this issue: https://u.pcloud.link/publink/show?code=XZ969y0Z02um8sNzzwkbXzScdMpvghiXOaBy

msrn commented 9 months ago

Apparently recent Dockerfile base-image change fixed RAW image thumbnail generation https://github.com/imagegenius/docker-immich/issues/208

But as tested with the latest image version, ORF files are still failing on thumbnail generation

jrasm91 commented 9 months ago

Verified that this works with vips 8.15.

lyonzy commented 9 months ago

This is still broken for me on 1.90.2:

[Nest] 8  - 12/14/2023, 12:31:01 AM   ERROR [JobService] Unable to run job handler (thumbnailGeneration/generate-jpeg-thumbnail): Error: Input file contains unsupported image format
[Nest] 8  - 12/14/2023, 12:31:01 AM   ERROR [JobService] Error: Input file contains unsupported image format
[Nest] 8  - 12/14/2023, 12:31:01 AM   ERROR [JobService] Object:
{
  "id": "8a519c99-716c-418a-b37a-5cadbb8123a4"
}
msrn commented 9 months ago

This is still broken for me on 1.90.2:

[Nest] 8  - 12/14/2023, 12:31:01 AM   ERROR [JobService] Unable to run job handler (thumbnailGeneration/generate-jpeg-thumbnail): Error: Input file contains unsupported image format
[Nest] 8  - 12/14/2023, 12:31:01 AM   ERROR [JobService] Error: Input file contains unsupported image format
[Nest] 8  - 12/14/2023, 12:31:01 AM   ERROR [JobService] Object:
{
  "id": "8a519c99-716c-418a-b37a-5cadbb8123a4"
}

The fix is not included in 1.90.2 it seems.

Main branch commit https://github.com/immich-app/immich/commit/02d55644e5001940fbf3480c3f891252baf24d3d doesn't have tag associated with it. So I assume it's going to be available in the next release