immich-app / immich

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

360 panorama in HEIF/HEIC format doesn't render #9509

Open bencefr opened 5 months ago

bencefr commented 5 months ago

The bug

Due to file size I prefer to keep my panoramas in HEIC format, but it turns out that currently Immich cannot handle them.

There are two issues:

  1. if the image dimensions exceed 16384x16384 the image cannot be decoded on the server

    immich_microservices     | [Nest] 7  - 05/15/2024, 8:27:57 AM   ERROR [ImmichMicroservices] [JobService] Unable to run job handler (thumbnailGeneration/generate-preview): Error: Input file has corrupt header: upload/library/admin/2024/2024-03-30/PANO0195.heic: bad seek to 17567657
    immich_microservices     | heif: Memory allocation error: Security limit exceeded: Image size 21694x10847 exceeds the maximum image size 16384x16384
    immich_microservices     |  (6.1000)
    immich_microservices     | [Nest] 7  - 05/15/2024, 8:27:57 AM   ERROR [ImmichMicroservices] [JobService] Error: Input file has corrupt header: upload/library/admin/2024/2024-03-30/PANO0195.heic: bad seek to 17567657
    immich_microservices     | heif: Memory allocation error: Security limit exceeded: Image size 21694x10847 exceeds the maximum image size 16384x16384
    immich_microservices     |  (6.1000)
    immich_microservices     |     at Sharp.toFile (/usr/src/app/node_modules/sharp/lib/output.js:89:19)
    immich_microservices     |     at MediaRepository.generateThumbnail (/usr/src/app/dist/repositories/media.repository.js:69:14)
    immich_microservices     |     at MediaService.generateThumbnail (/usr/src/app/dist/services/media.service.js:158:48)
    immich_microservices     |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    immich_microservices     |     at async MediaService.handleGeneratePreview (/usr/src/app/dist/services/media.service.js:135:29)
    immich_microservices     |     at async /usr/src/app/dist/services/job.service.js:145:36
    immich_microservices     |     at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:394:28)
    immich_microservices     |     at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:581:24)
    Screenshot 2024-05-15 at 10 31 52
  2. if I scale down the image (not intended), the server has no issues but the web viewer chokes on it

    Screenshot 2024-05-15 at 11 04 32 Screenshot 2024-05-15 at 10 46 51

The OS that Immich Server is running on

Docker on Ubuntu

Version of Immich Server

v1.105.1

Version of Immich Mobile App

v1.105.1

Platform with the issue

Your docker-compose.yml content

not relevant

Your .env content

not relevant

Reproduction steps

1. Upload a 360 pano that is converted to HEIF/HEIC
2. Try to view it

Relevant log output

No response

Additional information

No response

kristof-mattei commented 4 months ago

This seems to be an issue upstream: https://github.com/strukturag/libheif

https://github.com/search?q=repo%3Astrukturag%2Flibheif%20Security%20limit%20exceeded&type=code

bencefr commented 3 months ago

This seems to be an issue upstream: https://github.com/strukturag/libheif

No, it's not, it's only an issue with default settings which can be changed.

grazy27 commented 2 months ago

Also heic is not natively supported by browsers, so immich can only suggest thumbnail of it instead of original photo, on 200MP from Samsung difference is huge.

Zoomed in example: image