Skip to content

Add use_srgb_color_profile argument to increase portability of screenshots - #52

Closed
nstrayer wants to merge 3 commits into
masterfrom
force-srgb-color-profile-default
Closed

nstrayer wants to merge 3 commits into
masterfrom
force-srgb-color-profile-default

Conversation

@nstrayer

@nstrayer nstrayer commented Jul 2, 2021

Copy link
Copy Markdown
Contributor

This is the same PR as rstudio/webshot2#23 just now applied at the chromote level so it doesn't have to be reimplemented by every wrapping package that will probably want the functionality.

By default, chromote will mirror the color profile of the main monitor of the machine used to take the screenshot. This means that screenshots taken on a laptop plugged into an external monitor will often have subtly different colors than one taken when the laptop is using its built-in monitor. This problem will be even more likely across machines.

To remedy this we set the Chrome headless argument force-color-profile to "srgb" so the color profile used is always the same across machines/monitors.

The use_srgb_color_profile argument defaults to TRUE. This may break visual tests that use screenshots generated by chromote but I think it's ultimately a better default than the non-portable mirroring of the current monitor's profile.

nstrayer added 3 commits July 2, 2021 11:02
…forcing color profile as srgb to improve portability
Previous advice of a two element array just flattened and treated the value as another argument, which could be dangerous...
@nstrayer
nstrayer requested a review from wch July 2, 2021 15:08
@nstrayer

nstrayer commented Jul 2, 2021

Copy link
Copy Markdown
Contributor Author

4930fe7 also updates the args documentation added in #51 to advise the use of single-character-string key-value args. The previous two-element advice was not ideal as these just got flattened.

Comment thread R/chrome.R


launch_chrome <- function(path = find_chrome(), args = character(0)) {
launch_chrome <- function(path = find_chrome(), use_srgb_color_profile = TRUE, args = character(0)) {

@wch wch Jul 2, 2021 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I think about this some more, I don't think we even need to make this optional -- we might as well always set it. (And same for the initialize() method)

Comment thread R/chrome.R
#' screenshotting machines have different color profiles. The downside is
#' that colors of output may be slightly different than what you see in
#' your browser.
#' Equivalent to settings `args = '--force-color-profile="srgb"'`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please re-wrap comments (Cmd-/ in RStudio) because they'll end up getting re-wrapped at some point in the future, and that will cause spurious changes.

@schloerke schloerke mentioned this pull request Jul 15, 2021
2 tasks done
schloerke added a commit that referenced this pull request Jul 16, 2021
@schloerke

Copy link
Copy Markdown
Collaborator

Closing in favor of #57 and #58

@schloerke schloerke closed this Jul 19, 2021
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.

3 participants