3
$\begingroup$

When I take a screenshot in macOS (cmd-shift-4) and then import into a notebook, the colors tend to look washed out. Can anyone reproduce this behavior, and is there a workaround?

For example let's take a screenshot of a green disk:

This image can be downloaded here.

Now let's import the screenshot and compare to what we see in Preview:

enter image description here

We can look at the image data to see it's indeed not RGBColor[0, 1, 0, 1]:

img = Import["/Users/ghurst/Dropbox/Screenshots/Screen Shot 2022-05-25 at 8.14.04 AM.png"];

ImageData[img][[500, 500]]
{0.454902, 0.988235, 0.298039, 1.}

Lastly, macOS's Digital Color Meter shows a difference:

enter image description here


It seems to be related to the image's color profile. Converting Green to the images profile gives roughly the same value as ImageData:

profile = Import["/Users/ghurst/Dropbox/Screenshots/Screen Shot 2022-05-25 at 8.14.04 AM.png", "ColorProfileData"];

ColorConvert[Green, profile]
RGBColor[0.458625, 0.984878, 0.298528]

Possibly the same question as here: Is Mathematica 10 color managed?

$\endgroup$
1
  • $\begingroup$ You can see with exiftool.exe that it has Display P3 color profile. That is sRGB transfer function, but primaries and white point are different with sRGB, those are P3-D65. On windows you have to color manage everything, while on macos OS does it. The display in Safari of that png would be correct. $\endgroup$ May 25 at 18:03

1 Answer 1

3
$\begingroup$

This seems to be a valid workaround, but it does change the data.

Note that this works in 12.3 but not 13.0!

file = "/Users/ghurst/Dropbox/Screenshots/Screen Shot 2022-05-25 at 8.14.04 AM.png";

img = Import[file];

profile = Import[file, "ColorProfileData"];

{img, ColorConvert[img, profile -> "RGB"]}

enter image description here


In version 13.0 the following seems to be a valid workaround. I was surprised to see the (new in 13) WhitePoint option have no effect.

ColorConvert[ColorConvert[img, profile -> "XYZ"], "RGB"]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.