[PR #4101] [MERGED] fix(server): use srgb pipeline for srgb images #10245

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

📋 Pull Request Information

Original PR: https://github.com/immich-app/immich/pull/4101
Author: @mertalev
Created: 9/15/2023
Status: Merged
Merged: 9/26/2023
Merged by: @jrasm91

Base: mainHead: fix/server-thumb-srgb-colorspace


📝 Commits (9)

  • e2e1d92 added color-related exif fields
  • 08d46c0 remove metadata check, conditional pipe colorspace
  • 7f34bca check exif metadata for srgb
  • ef737e9 added migration
  • e5114c8 updated e2e fixture
  • fd678f3 uncased srgb check, search substrings
  • eba7dd1 extracted exif logic into separate function
  • 21b1bc4 handle images with no bit depth or color metadata
  • c328190 added unit tests

📊 Changes

7 files changed (+155 additions, -17 deletions)

View changed files

📝 server/src/domain/media/media.service.spec.ts (+84 -1)
📝 server/src/domain/media/media.service.ts (+16 -2)
📝 server/src/infra/entities/exif.entity.ts (+9 -0)
server/src/infra/migrations/1694750975773-AddExifColorSpace.ts (+18 -0)
📝 server/src/infra/repositories/media.repository.ts (+2 -14)
📝 server/src/microservices/processors/metadata-extraction.processor.ts (+23 -0)
📝 server/test/fixtures/shared-link.stub.ts (+3 -0)

📄 Description

Description

There's a bug with sharp regarding sRGB images where the combination of pipelineColorspace('rgb16') and withMetadata causes the output image to become more saturated. There's a similar issue for this in sharp that will be fixed in the next release, but from local testing it doesn't fix this particular issue. I believe it stems from libvips treating all 8-bit RGB as sRGB and sharp treating all 16-bit RGB as P3. This PR handles this by looking at exif metadata to decide whether an image is sRGB. It mostly maintains current behavior until metadata extraction is run for images, at which point it processes them correctly.

Fixes the issue described here

How Has This Been Tested?

I ran thumbnail generation without any metadata extraction and observed that while non-sRGB images were processed correctly, sRGB thumbnails were more saturated. After running metadata extraction and re-running thumbnail generation, sRGB images have more accurate colors while non-sRGB images are the same.


🔄 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/4101 **Author:** [@mertalev](https://github.com/mertalev) **Created:** 9/15/2023 **Status:** ✅ Merged **Merged:** 9/26/2023 **Merged by:** [@jrasm91](https://github.com/jrasm91) **Base:** `main` ← **Head:** `fix/server-thumb-srgb-colorspace` --- ### 📝 Commits (9) - [`e2e1d92`](https://github.com/immich-app/immich/commit/e2e1d9230cbb8a75dc8180f1c40d8878dbc991d8) added color-related exif fields - [`08d46c0`](https://github.com/immich-app/immich/commit/08d46c0f983e5e841d44d60d71b193f6e77f716f) remove metadata check, conditional pipe colorspace - [`7f34bca`](https://github.com/immich-app/immich/commit/7f34bca62e4cc2d3488dba8872466e69d3ba0de7) check exif metadata for srgb - [`ef737e9`](https://github.com/immich-app/immich/commit/ef737e92398d6f0da0d992c447d20d29326ef74e) added migration - [`e5114c8`](https://github.com/immich-app/immich/commit/e5114c8278b28cc187bc776413becf83f6289d46) updated e2e fixture - [`fd678f3`](https://github.com/immich-app/immich/commit/fd678f30b548038f8597369f91dc7211c05f6fca) uncased srgb check, search substrings - [`eba7dd1`](https://github.com/immich-app/immich/commit/eba7dd182a75f447629b455b5b0caa896c1db472) extracted exif logic into separate function - [`21b1bc4`](https://github.com/immich-app/immich/commit/21b1bc44f0266aa165b5baa65e264be570788071) handle images with no bit depth or color metadata - [`c328190`](https://github.com/immich-app/immich/commit/c328190efc4decd17a10f6cec7d9c9bffaba0064) added unit tests ### 📊 Changes **7 files changed** (+155 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `server/src/domain/media/media.service.spec.ts` (+84 -1) 📝 `server/src/domain/media/media.service.ts` (+16 -2) 📝 `server/src/infra/entities/exif.entity.ts` (+9 -0) ➕ `server/src/infra/migrations/1694750975773-AddExifColorSpace.ts` (+18 -0) 📝 `server/src/infra/repositories/media.repository.ts` (+2 -14) 📝 `server/src/microservices/processors/metadata-extraction.processor.ts` (+23 -0) 📝 `server/test/fixtures/shared-link.stub.ts` (+3 -0) </details> ### 📄 Description ## Description There's a bug with sharp regarding sRGB images where the combination of `pipelineColorspace('rgb16')` and `withMetadata` causes the output image to become more saturated. There's a similar issue for this in sharp that will be fixed in the next release, but from local testing it doesn't fix this particular issue. I believe it stems from libvips treating all 8-bit RGB as sRGB and sharp treating all 16-bit RGB as P3. This PR handles this by looking at exif metadata to decide whether an image is sRGB. It mostly maintains current behavior until metadata extraction is run for images, at which point it processes them correctly. Fixes the issue described [here](https://github.com/immich-app/immich/pull/4040#issuecomment-1716196839) ## How Has This Been Tested? I ran thumbnail generation without any metadata extraction and observed that while non-sRGB images were processed correctly, sRGB thumbnails were more saturated. After running metadata extraction and re-running thumbnail generation, sRGB images have more accurate colors while non-sRGB images are the same. --- <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:18:24 +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#10245