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

Unsupported color conversion when trying to convert 200MP heif images taken on S24 Ultra #4335

Open
5 tasks done
Iaotle opened this issue Feb 19, 2025 · 1 comment
Open
5 tasks done

Comments

@Iaotle
Copy link

Iaotle commented Feb 19, 2025

Possible bug

  • Running npm install sharp completes without error.
  • Running node -e "require('sharp')" completes without error.
  • I am using the latest version of sharp as reported by npm view sharp dist-tags.latest.
  • Adding sharp.cache(false) does not fix this problem.
  • Using rotate() or keepExif() does not fix this problem.

What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?

System:
    OS: Linux 5.15 Debian GNU/Linux trixie/sid
    CPU: (8) x64 Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
    Memory: 53.78 GB / 62.72 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 22.13.1 - /usr/local/bin/node
    Yarn: 1.22.22 - /usr/local/bin/yarn
    npm: 10.9.2 - /usr/local/bin/npm

My apologies in advance if this is not an issue with sharp, though it seems to be either that or configuration, and since I'm not familiar with sharp I thought it would be prudent to ask here, so that I may be directed towards the responsible vendor/package with more info on what's going wrong. I've already looked into libheif, and it seems that the issue does not lie there (see strukturag/libheif#1259). The relevant immich configuration also seems to me to be correct (https://github.com/immich-app/immich/blob/376282e538becf6887504965ac8b3f02ec3389b9/server/src/services/media.service.ts#L202).

What are the steps to reproduce?

Grab heic image with the following dimensions: (200 MP 12240 x 16320 4 MiB).
Setup immich using the dockerfile (easy config for reproducing the issue, I already took the step of updating sharp to the latest version manually and that doesn't solve the issue).

Then I get this:

2025-02-19 23:43:02 [Nest] 7  - 02/19/2025, 11:43:02 PM   ERROR [Microservices:JobService] Error: heif: Unsupported feature: Unsupported color conversion (4.3003)
2025-02-19 23:43:02     at Sharp.toBuffer (/usr/src/app/node_modules/sharp/lib/output.js:163:17)
2025-02-19 23:43:02     at MediaRepository.decodeImage (/usr/src/app/dist/repositories/media.repository.js:54:68)
2025-02-19 23:43:02     at MediaService.generateImageThumbnails (/usr/src/app/dist/services/media.service.js:164:63)
2025-02-19 23:43:02     at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
2025-02-19 23:43:02     at async MediaService.handleGenerateThumbnails (/usr/src/app/dist/services/media.service.js:114:25)
2025-02-19 23:43:02     at async JobService.onJobStart (/usr/src/app/dist/services/job.service.js:148:28)
2025-02-19 23:43:02     at async EventRepository.onEvent (/usr/src/app/dist/repositories/event.repository.js:130:13)
2025-02-19 23:43:02     at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:394:28)
2025-02-19 23:43:02     at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:581:24)

What is the expected behaviour?

Thumbnail generation should work

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem

Docker container should be very easy to set up, and uploading the image should trigger this immediately with no additional setup: https://immich.app/docs/install/docker-compose/

Please provide sample image(s) that help explain this problem

Download the image in question from my share: https://mega.nz/file/r04x1DTD#X8q1hVzAPNfya_ZXizn8HPEOZRFRNRq0DaRpJyX6hwc

@lovell
Copy link
Owner

lovell commented Feb 20, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants