Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support colorSpace attribute for canvas resize? #249

Open
tomdav999 opened this issue Dec 26, 2024 · 0 comments
Open

Support colorSpace attribute for canvas resize? #249

tomdav999 opened this issue Dec 26, 2024 · 0 comments

Comments

@tomdav999
Copy link

tomdav999 commented Dec 26, 2024

Hi, just wondering if you could tweak the code support the 2d context colorSpace attribute:

let canvas = document.getElementById("myCanvas");
let options = { colorSpace: "display-p3"};
const context = canvas.getContext("2d", options);

Currently, pica does not provide a way to set this attribute. Images without a sRGB profile are converted to sRGB (by default if no colorSpace attribute is specified). I believe setting the colorSpace attribute to "display-p3" (for images with this embedded profile) would preserve the color profile. It would also make sense for images with wider gamut profiles than "display-P3" (better than converting to sRGB).

Also, currently the color profile does not get added back by the image-blob-reduce wrapper, which makes sense if colors are converted to sRGB. However, if setting the colorSpace attribute to "display-p3", this ICC profile should be added to the saved image.

Hopefully this makes sense. I could modify the code myself but there are so many places where getContext is used, not sure if all of these need to be modified, and I'm not exactly sure how to add back the ICC profile.

@tomdav999 tomdav999 changed the title Add options object support for canvas resize? Support colorSpace attribute for canvas resize? Dec 27, 2024
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

No branches or pull requests

1 participant