[PR #3658] [MERGED] feat(server): wide gamut thumbnails #10068

Closed
opened 2026-02-05 14:15:30 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/immich-app/immich/pull/3658
Author: @mertalev
Created: 8/13/2023
Status: Merged
Merged: 9/3/2023
Merged by: @mertalev

Base: mainHead: feat/server-wide-gamut


📝 Commits (10+)

📊 Changes

27 files changed (+405 additions, -61 deletions)

View changed files

📝 cli/src/api/open-api/api.ts (+28 -0)
📝 mobile/openapi/.openapi-generator/FILES (+3 -0)
📝 mobile/openapi/README.md (+1 -0)
mobile/openapi/doc/Colorspace.md (+14 -0)
📝 mobile/openapi/doc/SystemConfigThumbnailDto.md (+2 -0)
📝 mobile/openapi/lib/api.dart (+1 -0)
📝 mobile/openapi/lib/api_client.dart (+2 -0)
📝 mobile/openapi/lib/api_helper.dart (+3 -0)
mobile/openapi/lib/model/colorspace.dart (+85 -0)
📝 mobile/openapi/lib/model/system_config_thumbnail_dto.dart (+17 -1)
mobile/openapi/test/colorspace_test.dart (+21 -0)
📝 mobile/openapi/test/system_config_thumbnail_dto_test.dart (+10 -0)
📝 server/immich-openapi-specs.json (+16 -1)
📝 server/src/domain/facial-recognition/facial-recognition.service.spec.ts (+7 -1)
📝 server/src/domain/facial-recognition/facial-recognition.services.ts (+8 -1)
📝 server/src/domain/media/media.repository.ts (+4 -1)
📝 server/src/domain/media/media.service.spec.ts (+14 -12)
📝 server/src/domain/media/media.service.ts (+47 -31)
📝 server/src/domain/media/media.util.ts (+7 -4)
📝 server/src/domain/system-config/dto/system-config-thumbnail.dto.ts (+15 -1)

...and 7 more files

📄 Description

Description

As requested in #3623, this PR allows for targeting Display P3 instead of sRGB for thumbnails, allowing for more vibrant images that better capture the colors of the original. Additionally, it adds a quality setting so users can customize thumbnail generation to their preference.

This only applies to image thumbnails for now, not video thumbnails. I tried several approaches for adding the same features for video thumbnails but wasn't satisfied with any of them:

  • FFmpeg does not tag the resulting image with an ICC profile even with -flags2 iccprofiles (added with this issue), so colors do not appear correctly

  • JPEG quality in FFmpeg ranges 1-31 (lower is better) instead of 1-100, and even the highest quality setting is notably worse than what sharp or Imagemagick produces

  • It is possible to extract a lossless thumbnail from FFmpeg and process it in sharp, but the resulting thumbnail naturally has different colors than the transcoded video

  • It is possible to target smpte432 for videos as well, but they don't seem to be processed correctly in Firefox (and applying a thumbnail setting to transcoding is confusing)

Fixes #3136

How Has This Been Tested?

I ran thumbnail generation on a library of a few thousand images, some of which are HDR images. Inspecting the thumbnails produced for these images with exiftool shows that they have the expected ICC profile. Comparing them to older thumbnails likewise shows the expected difference in color.

Before:

before

After:

after

(Credits to @adambeck7 for the image)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/immich-app/immich/pull/3658 **Author:** [@mertalev](https://github.com/mertalev) **Created:** 8/13/2023 **Status:** ✅ Merged **Merged:** 9/3/2023 **Merged by:** [@mertalev](https://github.com/mertalev) **Base:** `main` ← **Head:** `feat/server-wide-gamut` --- ### 📝 Commits (10+) - [`91a7f9b`](https://github.com/immich-app/immich/commit/91a7f9b24f7ab67273a05ac44afa8a2747ed2b6e) added wide gamut support - [`3f30d1f`](https://github.com/immich-app/immich/commit/3f30d1fac0b223a95731558d3d12f403d7338742) fixed jpeg quality setting for ffmpeg - [`92a4212`](https://github.com/immich-app/immich/commit/92a4212bcf3f9bbc75e7c8d1e433fbcdea4f9150) revert thumbnail refactor - [`8000e61`](https://github.com/immich-app/immich/commit/8000e614f3488f57166833c77a3ff66ab7c4213e) updated api - [`c97b872`](https://github.com/immich-app/immich/commit/c97b87279a2b4012e44c24c01c02eae7b0b5a4eb) added settings to accordion - [`dc37c5c`](https://github.com/immich-app/immich/commit/dc37c5ce883ffe3a091d65b400f019bdd7ced59f) revert video thumbnail changes - [`9b1822d`](https://github.com/immich-app/immich/commit/9b1822dae629c456e612b3393d75cafa776949e6) fixed icc profile not being tagged - [`9feffc8`](https://github.com/immich-app/immich/commit/9feffc8ab97cdb120fcf1a1dc08ce87291fc34b8) updated tests, formatting - [`687b0d5`](https://github.com/immich-app/immich/commit/687b0d508c9deb5e04467a443cb8e78665eec5fc) fixed crashing - [`740aaa4`](https://github.com/immich-app/immich/commit/740aaa48ee027b56f277069eec7d709fd3c5bfd8) handle videos for webp ### 📊 Changes **27 files changed** (+405 additions, -61 deletions) <details> <summary>View changed files</summary> 📝 `cli/src/api/open-api/api.ts` (+28 -0) 📝 `mobile/openapi/.openapi-generator/FILES` (+3 -0) 📝 `mobile/openapi/README.md` (+1 -0) ➕ `mobile/openapi/doc/Colorspace.md` (+14 -0) 📝 `mobile/openapi/doc/SystemConfigThumbnailDto.md` (+2 -0) 📝 `mobile/openapi/lib/api.dart` (+1 -0) 📝 `mobile/openapi/lib/api_client.dart` (+2 -0) 📝 `mobile/openapi/lib/api_helper.dart` (+3 -0) ➕ `mobile/openapi/lib/model/colorspace.dart` (+85 -0) 📝 `mobile/openapi/lib/model/system_config_thumbnail_dto.dart` (+17 -1) ➕ `mobile/openapi/test/colorspace_test.dart` (+21 -0) 📝 `mobile/openapi/test/system_config_thumbnail_dto_test.dart` (+10 -0) 📝 `server/immich-openapi-specs.json` (+16 -1) 📝 `server/src/domain/facial-recognition/facial-recognition.service.spec.ts` (+7 -1) 📝 `server/src/domain/facial-recognition/facial-recognition.services.ts` (+8 -1) 📝 `server/src/domain/media/media.repository.ts` (+4 -1) 📝 `server/src/domain/media/media.service.spec.ts` (+14 -12) 📝 `server/src/domain/media/media.service.ts` (+47 -31) 📝 `server/src/domain/media/media.util.ts` (+7 -4) 📝 `server/src/domain/system-config/dto/system-config-thumbnail.dto.ts` (+15 -1) _...and 7 more files_ </details> ### 📄 Description ## Description As requested in #3623, this PR allows for targeting Display P3 instead of sRGB for thumbnails, allowing for more vibrant images that better capture the colors of the original. Additionally, it adds a quality setting so users can customize thumbnail generation to their preference. This only applies to image thumbnails for now, not video thumbnails. I tried several approaches for adding the same features for video thumbnails but wasn't satisfied with any of them: * FFmpeg does not tag the resulting image with an ICC profile even with `-flags2 iccprofiles` (added with [this](https://trac.ffmpeg.org/ticket/9672) issue), so colors do not appear correctly * JPEG quality in FFmpeg ranges 1-31 (lower is better) instead of 1-100, and even the highest quality setting is notably worse than what sharp or Imagemagick produces * It is possible to extract a lossless thumbnail from FFmpeg and process it in sharp, but the resulting thumbnail naturally has different colors than the transcoded video * It is possible to target `smpte432` for videos as well, but they don't seem to be processed correctly in Firefox (and applying a thumbnail setting to transcoding is confusing) Fixes #3136 ## How Has This Been Tested? I ran thumbnail generation on a library of a few thousand images, some of which are HDR images. Inspecting the thumbnails produced for these images with exiftool shows that they have the expected ICC profile. Comparing them to older thumbnails likewise shows the expected difference in color. Before: ![before](https://github.com/immich-app/immich/assets/101130780/fe7e9532-058d-4b50-bdef-7355a3a636ec) After: ![after](https://github.com/immich-app/immich/assets/101130780/ab3fef15-438a-4a68-9b5a-fbb7f34cd64f) (Credits to @adambeck7 for the image) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 14:15:30 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#10068