immich icon indicating copy to clipboard operation
immich copied to clipboard

Error: heif: Unsupported feature: Unsupported color conversion (4.3003)

Open flosoft opened this issue 1 year ago • 9 comments

The bug

Immich seems to have issues with the 200MP photos from my Samsung Galaxy S24. The picture has been uploaded directly to the file storage and is mounted into Immich via an external library.

The Image that fails can be found here: https://pam.bcn.jensen.ovh/sharing/tLiM6m1xY

The OS that Immich Server is running on

Docker

Version of Immich Server

V1.121.0

Version of Immich Mobile App

V1.121.0 build.168

Platform with the issue

  • [X] Server
  • [ ] Web
  • [ ] Mobile

Your docker-compose.yml content

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /volume1/photo/:/mnt/photo:ro
      - /var/services/homes/florian/Photos:/mnt/photo-florian:ro
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    ports:
      - 2283:2283
    depends_on:
      - redis
      - database
    restart: always
  immich-machine-learning:
    container_name: immich_machine_learning
    # For hardware acceleration, add one of -[armnn, cuda, openvino] to the image tag.
    # Example tag: ${IMMICH_VERSION:-release}-cuda
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    #extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/ml-hardware-acceleration
    #  file: hwaccel.ml.yml
    #  service: openvino # set to one of [armnn, cuda, openvino, openvino-wsl] for accelerated inference - use the `-wsl` version for WSL2 where applicable
    volumes:
      - model-cache:/cache
    env_file:
      - .env
    restart: always
  redis:
    container_name: immich_redis
    image: registry.hub.docker.com/library/redis:6.2-alpine@sha256:51d6c56749a4243096327e3fb964a48ed92254357108449cb6e23999c37773c5
    restart: always
  database:
    container_name: immich_postgres
    image: registry.hub.docker.com/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0
    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:

Your .env content

UPLOAD_LOCATION=./library
IMMICH_VERSION=release
DB_PASSWORD=#########
DB_HOSTNAME=immich_postgres
DB_USERNAME=#######
DB_DATABASE_NAME=#######
REDIS_HOSTNAME=immich_redis

Reproduction steps

Upload image to server. Refresh image thumbnails. Image thumbnail generation will continue to fail.

Relevant log output

immich_server            | [Nest] 7  - 11/24/2024, 2:24:15 PM   ERROR [Microservices:JobService] Unable to run job handler (thumbnailGeneration/generate-thumbnails): Error: heif: Unsupported feature: Unsupported color conversion (4.3003)
immich_server            | [Nest] 7  - 11/24/2024, 2:24:15 PM   ERROR [Microservices:JobService] Error: heif: Unsupported feature: Unsupported color conversion (4.3003)
immich_server            |     at Sharp.toBuffer (/usr/src/app/node_modules/sharp/lib/output.js:163:17)
immich_server            |     at MediaRepository.decodeImage (/usr/src/app/dist/repositories/media.repository.js:57:68)
immich_server            |     at MediaService.generateImageThumbnails (/usr/src/app/dist/services/media.service.js:158:63)
immich_server            |     at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
immich_server            |     at async MediaService.handleGenerateThumbnails (/usr/src/app/dist/services/media.service.js:108:25)
immich_server            |     at async JobService.onJobStart (/usr/src/app/dist/services/job.service.js:151:28)
immich_server            |     at async EventRepository.onEvent (/usr/src/app/dist/repositories/event.repository.js:122:13)
immich_server            |     at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:394:28)
immich_server            |     at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:581:24)
immich_server            | [Nest] 7  - 11/24/2024, 2:24:15 PM   ERROR [Microservices:JobService] Object:
immich_server            | {
immich_server            |   "id": "85d4b07f-18cb-45e0-8a6e-f75b46a31de4"
immich_server            | }
immich_server            |


### Additional information

_No response_

flosoft avatar Nov 24 '24 14:11 flosoft

I'm having the same issue with all 200MP heic pictures from my samsung Galaxy S23.

C4rbon14 avatar Nov 29 '24 23:11 C4rbon14

having also the same issue with s24 ultra and 200MP heic pictures

dbart37 avatar Dec 07 '24 22:12 dbart37

Same behavior with several 200MP HEIC files from Galaxy S24 Ultra on latest version 1.122.2

rrombu avatar Dec 10 '24 16:12 rrombu

Still present in v1.123.0

dbart37 avatar Dec 20 '24 15:12 dbart37

The issue is still opened, which means we haven't gotten to it yet :)

alextran1502 avatar Dec 20 '24 16:12 alextran1502

The issue is still opened, which means we haven't gotten to it yet :)

Sorry Alex for my impatience. I love your job here. Happy New Year

dbart37 avatar Dec 20 '24 22:12 dbart37

It would really be nice if this was fixed, missing thumbnails make it hard to find what I'm looking for sometimes, and other than that Immich is such a great app now :)

Iaotle avatar Feb 03 '25 12:02 Iaotle

I've made an issue on Sharp, and this issue should be solved when the next release of libvips (PR already merged) is out, and when Sharp updates the dependency. So hopefully everything works once those dependencies are updated here in Immich.

Iaotle avatar Mar 02 '25 13:03 Iaotle

Thanks for getting this fixed upstream! Now we just need to wait for the next libvips release to come out.

mertalev avatar Mar 02 '25 18:03 mertalev

RC has been published with a fix: https://github.com/libvips/libvips/releases/tag/v8.17.0-test1

MoweME avatar Mar 11 '25 14:03 MoweME

@MoweME haha I'm also checking every couple days :D

Iaotle avatar Mar 11 '25 14:03 Iaotle

I now get a different error when trying to generate thumbnails for those pictures:

2025-04-23T19:49:46.301382636Z [Nest] 7  - 04/23/2025, 1:49:46 PM   ERROR [Microservices:{"id":"278c1c27-1d8e-4079-916b-1fef99f6e3e9"}] Unable to run job handler (thumbnailGeneration/generate-thumbnails): Error: heif: Memory allocation error: Security limit exceeded: Allocating 599270415 bytes exceeds the security limit of 536870912 bytes (6.1000)

2025-04-23T19:49:46.301456576Z Error: heif: Memory allocation error: Security limit exceeded: Allocating 599270415 bytes exceeds the security limit of 536870912 bytes (6.1000)

2025-04-23T19:49:46.301467231Z     at Sharp.toBuffer (/usr/src/app/node_modules/sharp/lib/output.js:163:17)

2025-04-23T19:49:46.301469156Z     at MediaRepository.decodeImage (/usr/src/app/dist/repositories/media.repository.js:97:68)

2025-04-23T19:49:46.301470881Z     at MediaService.generateImageThumbnails (/usr/src/app/dist/services/media.service.js:181:59)

2025-04-23T19:49:46.301472963Z     at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

2025-04-23T19:49:46.301474600Z     at async MediaService.handleGenerateThumbnails (/usr/src/app/dist/services/media.service.js:103:25)

2025-04-23T19:49:46.301476232Z     at async JobService.onJobStart (/usr/src/app/dist/services/job.service.js:166:28)

2025-04-23T19:49:46.301477765Z     at async EventRepository.onEvent (/usr/src/app/dist/repositories/event.repository.js:126:13)

2025-04-23T19:49:46.301479302Z     at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:394:28)

2025-04-23T19:49:46.301480857Z     at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:581:24)

C4rbon14 avatar Apr 23 '25 19:04 C4rbon14

Yes, the -unlimited flag needs to be set:

https://github.com/lovell/sharp/issues/4335#issuecomment-2671915115 I've been able to reproduce and it looks like this relates to libheif security limits (the error message is somewhat misleading).

The unlimited flag provided by sharp and libvips when opening HEIF images currently only removes the security limit on image dimensions, whereas libheif 1.19.0 onwards provides more granular control over these.

I've opened a libvips PR libvips/libvips#4398 to take advantage of this new feature. This change allows me to process the sample image provided locally without error.

@alextran1502 it looks like all you need to do to solve this issue for all devices, since now the limits will be removed, and future high-resolution images should work no problem for thumbnail generation :)

Iaotle avatar Apr 23 '25 19:04 Iaotle

I am having the same issue on the Latest Immich version 1.135.3 from Galaxy S24 Ultra 200MP images. Having thew same error and "Error Loading Image" because of this for all images in 200MP specifically from this phone only. Facing this Issue on Web and Mobile app. Also the Latest version of https://github.com/libvips/libvips/releases/tag/v8.17.0 has been released about a month ago

saineela avatar Jun 30 '25 14:06 saineela

Also the Latest version of https://github.com/libvips/libvips/releases/tag/v8.17.0 has been released about a month ago

We use libvips through sharp, which has not made a release for 8.17 yet (only a release candidate).

mertalev avatar Jul 02 '25 19:07 mertalev

@alextran1502

sharp v0.34.3 is now available with prebuilt binaries that include the upstream change to libvips. You'll need to set the unlimited flag to read these images, but please ensure you trust their source before doing so.

Iaotle avatar Jul 15 '25 02:07 Iaotle

waiting new version

Saopanda avatar Jul 17 '25 01:07 Saopanda

I've created #20327 which bumps sharp and adds the unlimited flag.

However, this depends on https://github.com/immich-app/base-images/pull/239.

simonhammes avatar Jul 27 '25 13:07 simonhammes

Same behavior with several 200MP HEIC files from Galaxy S24 Ultra on latest version 1.122.2

is that why this happens? I have the S23 ultra, and since the pictures from the 12 MP sensors work fine in Immich, I assumed it was simply too large of a resolution (16320 x 12240) - I wouldn't expect the images to be stored with different color settings or whatever

Edit: I've also noticed my 50 MP photos look fine, and those come from the 200 MP sensor, as far as I can tell, they're simply binned

Magicrafter13 avatar Aug 16 '25 21:08 Magicrafter13

It looks like the upstream issue has been fixed and merged into the base-images repository. Is it this issue resolved now then?

jrasm91 avatar Aug 29 '25 23:08 jrasm91

I am not sure, Will update it to latest version and check @jrasm91.

saineela avatar Aug 29 '25 23:08 saineela

I believe it still needs #20327

mertalev avatar Aug 29 '25 23:08 mertalev

Fixed via #21596

mertalev avatar Sep 04 '25 19:09 mertalev