Skip to content

Normalize image color spaces before comparison#665

Open
ejensen wants to merge 3 commits into
pointfreeco:mainfrom
Frameio:image-colorspace-coversions
Open

Normalize image color spaces before comparison#665
ejensen wants to merge 3 commits into
pointfreeco:mainfrom
Frameio:image-colorspace-coversions

Conversation

@ejensen

@ejensen ejensen commented Oct 22, 2022

Copy link
Copy Markdown
Contributor

Overview

Use the sRGB converted snapshot when doing the perceptual comparison. This reduces the chances of failures when comparing snapshots using different color spaces.

This colorspace normalization technique was originally introduced in #446 and this PR extends it to both the reference and new images when performing perceptual image comparison.

Unit tests were added to verify that images in the P3 and sRGB colors spaces match after colorspace normalization.

Related Issues

Use the sRGB converted snapshot when doing the perceptual comparison

This reduces the chances of failures when comparing snapshots in different color spaces
@pilot34

pilot34 commented Oct 2, 2023

Copy link
Copy Markdown

Hey. Should we merge this PR after the rebase? Looks like it was approved, but never merged

@Kaspik

Kaspik commented Oct 11, 2023

Copy link
Copy Markdown

@stephencelis Please, is there a plan to merge this?

# Conflicts:
#	Sources/SnapshotTesting/Snapshotting/NSImage.swift
#	Sources/SnapshotTesting/Snapshotting/UIImage.swift
#	Tests/SnapshotTestingTests/SnapshotTestingTests.swift
@ogiba

ogiba commented Apr 22, 2024

Copy link
Copy Markdown

@stephencelis I will bump this topic cause there was no answer from few months

Could you provide information what is blocking you from merging it into the main branch?

It will be nice feature/fix that could reduce lots of issues.

Thanks!

@brucerune

Copy link
Copy Markdown

+1 please merge :)

@adarhef

adarhef commented Oct 28, 2024

Copy link
Copy Markdown

After a while I figured out the difference between my CI machine and the dev machine was the color space, running on macOS.
Right now I simply normalize the NSWindow used for comparison by setting its color space to sRGB in my snapshotting strategy.
I imagine it won't be necessary if this PR is merged, but I imagine it might not be merged.
While users not understanding failures are due to color space differences is problematic (like just happened to me), I can imagine users might be surprised if images look different in the screenshots they take compared with what the interface looks like when just running on their dev machine.
It might be better to inform people about color space normalization so they can be intentional with their color space choice.
Just a thought

# Conflicts:
#	Tests/SnapshotTestingTests/SnapshotTestingTests.swift
@ejensen

ejensen commented Feb 14, 2025

Copy link
Copy Markdown
Contributor Author

Hi @mbrandonw or @stephencelis, would one of you be able to look at this PR? It has been waiting for a while and addresses issues when collaborating with people using various hardware to run snapshot tests. At least six other people (unaffiliated with me) stated they are experiencing these issues.

@AndreasInk

Copy link
Copy Markdown

I'm also experiencing this issue, would love to see this merged @stephencelis @mbrandonw

@mykrobot

Copy link
Copy Markdown

I am experiencing these issues as well, hoping to see this merged soon. @mbrandonw & @stephencelis any updates?

@yokoboko

yokoboko commented Aug 4, 2025

Copy link
Copy Markdown

We're experiencing the same issue. Hoping this will be resolved soon by normalizing the snapshot colors—this change is definitely needed. Thanks!

@jiayangmiao

Copy link
Copy Markdown

Any chance to check on conflicts and merge these? I am experiencing these issues too.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.