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

createImageBitmap: Clarify treatment of colorSpaceConversion:"none" ImageBitmaps #10578

Open
ccameron-chromium opened this issue Aug 26, 2024 · 8 comments
Labels
clarification Standard could be clearer topic: canvas

Comments

@ccameron-chromium
Copy link
Contributor

What is the issue with the HTML Standard?

When createImageBitmap is called with colorSpaceConversion:"none", the spec indicates the following:

  • If val is "none", output must be decoded without performing any color space conversions. This means that the image decoding algorithm must ignore color profile metadata embedded in the source data as well as the display device color profile.

It would be helpful to to clarify that the result will be an ImageBitmap that has been stripped of its color space information, and is therefore treated like all other images that have no color profile metadata (see here in canvas and here in CSS color). In particular, the raw RGB color values from the source will be treated as though they are in the sRGB color space.

Most likely this is best accomplished via an informative note, as is the case in the canvas section.

@ccameron-chromium
Copy link
Contributor Author

It should also be clarified that YUV to RGB conversions will be performed (it's the rest of the color space conversion that will not be performed).

@annevk
Copy link
Member

annevk commented Aug 27, 2024

Are there tests covering this?

cc @whatwg/canvas

@kenrussell
Copy link
Member

There are some tests of uploading images with "strange" colorspaces in https://github.com/KhronosGroup/WebGL . Specifically, the assets are under https://github.com/KhronosGroup/WebGL/tree/main/sdk/tests/resources , and the more strenuous ones have names like small-square-with-colorspin-profile.jpg and small-square-with-colorspin-profile.png. Feel free to copy these into any new tests for the HTML spec. Tests of other media types like videos still need to be written.

@ccameron-chromium
Copy link
Contributor Author

Are there tests covering this?

There is also wpt/html/canvas/element/manual/imagebitmap/createImageBitmap-colorSpaceConversion.html, which tests this with 2D canvas. It currently only does HTMLImageElement and Blob, but I'm updating it to include ImageData, HTMLCanvasElement, and HTMLVideoElement.

@sandstrom
Copy link

Maybe off topic, but it would be awesome if the interop 2024 team could iron out the problems surrounding createImageBitmap.

It would be a great API if it was usable, for example for image resizing after taking a photo using the camera, via <input type='file' multiple accept='image/*' capture='environment'>.

However, there are a bunch of bugs open on both Firefox, Chromium and Safari, around image quality issues, EXIF rotation and other things.

I think if those could be solved, this API would enable a lot of great utility! But right now, it isn't quite there.

@annevk
Copy link
Member

annevk commented Sep 19, 2024

@sandstrom good idea, but indeed the wrong place. Please suggest that over at https://github.com/web-platform-tests/interop/issues as a new issue.

@sandstrom
Copy link

@annevk Thanks! 😄

@sandstrom
Copy link

sandstrom commented Sep 22, 2024

@annevk I've added an issue here:

web-platform-tests/interop#731

It's my first submission, anything obvious that I've missed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification Standard could be clearer topic: canvas
Development

No branches or pull requests

4 participants