-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Adds convertToBlob to Canvas #3926
base: main
Are you sure you want to change the base?
Conversation
@whatwg/canvas (In case the original didn't work) |
Couple of comments:
Hope that helps. |
I did the |
You have to pick an order and build the PRs on each other, I think. Either we extend |
(The other PR is #3882 by the way, for those wondering.) |
@annevk's comments generally make sense. Another point to watch out for is how you've changed things compared to the existing algorithm at https://html.spec.whatwg.org/#dom-offscreencanvas-converttoblob. Are all of these changes intentional?
|
c71458e
to
1ac158a
Compare
There's an Intent to Ship: Canvas Color Management on blink-dev now, pointing back to this PR and #3882. @annevk @domenic, do either of you have the bandwidth to keep reviewing this? @fserb, I see the "needs tests" label, do the tests in https://wpt.fyi/results/2dcontext/wide-gamut-canvas fully cover the changes in this PR, or are more needed? |
I'll answer my own question about tests, looks like the only tests involving |
Documentation need recorded on MDN content roadmap at https://trello.com/c/N0hJJV95/129-2d-canvas-api |
source
Outdated
dictionary <dfn>ImageEncodeOptions</dfn> { | ||
DOMString <span data-x="image-encode-options-type">type</span> = "image/png"; | ||
unrestricted double <span data-x="image-encode-options-quality">quality</span> = 1.0; | ||
<span>ImageEncodePixelFormat</span> <span data-x="image-encode-options-pixelformat">pixelFormat</span> = "uint8"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This option isn't really explained in sufficient detail. Also, I thought we'd postpone adding it to a subsequent PR and only deal with convertToBlob()
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okey, I'll leave just the convertToBlob part.
@foolip I'm not sure we have other reviewers available? I think the main problem I have at times is the lag between reviews and updates and that probably goes both ways. Not sure what we can do to make that better. Perhaps at times synchronously communicate? |
@foolip, we do have canvas |
Oh, there it is. I must have made a typo when grepping. |
d8ead47
to
d33ff1b
Compare
Trying to make those PRs smaller. This one now just moves convertToBlob to also include Canvas. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there tests for this?
The one other problem here that was already a problem is that we don't parse the MIME type argument and we don't state how we set the MIME type for the resulting Blob
object. It would be good to make that use the MIME type infrastructure of the web platform and be clear if any unknown parameters get passed through, result in rejection, etc.
I also wonder if we should preserve the old ID for |
Done all. PTAL. |
(You also didn't reply to a bunch of the non-code questions/comments?) |
Regarding the WPT tests, we have a canvas-colorManaged-convertToBlob-roundtrip.html But we could probably add more tests. I agree that given that I'll work on additional resolution steps for the MIME type. |
@annevk is that what you had in mind? |
Put convertToBlob/toDataURL/toBlob together in a "Serializing canvas bitmaps" section, and merged that with the former "Serializing bitmaps to a file" section
Can't link to specific concepts since they're polymorphic
I'm pushing some last fixes. That will include reverting the MIME type work because I think it's too involved to get in to now. In particular we need to treat the three conversion functions the same way, which we currently are not. It's better to leave it as-is. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With my latest pushes this LGTM. @annevk for a final look?
Are there other implementers from @whatwg/canvas interested in allowing convertToBlob() on <canvas>
elements, not just OffscreenCanvas
es?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reordering makes this hard to review, but I guess it's okay? And yeah, it seems like what's still lacking is impl interest and tests. A follow-up issue for MIME types might be good too.
Scratch that question, the answer is: "seems like what's still lacking is impl interest and tests" @fserb, will you be adding more tests for this? |
On impl interest, @smfr commented in #4167 (comment) with support. |
Right, I understand there's interest from Google, but we need two implementers per https://whatwg.org/working-mode#changes. |
@smfr doesn't work for Google :) |
That's true, though that comment wasn't very specific (seemed to be mostly about the float16 backing store). In any event, we also seem to be waiting on tests as you noted earlier. |
What's the status here? Has this been implemented/shipped/abandoned? |
This has been implemented on Chrome but not shipped. It's one of those things that people will need once other color management feature gets traction (as will there be no way to export a canvas with a specified color space). Which I think is why @foolip suggested that support for color management kinda implies support for this. It's also a better API, and already implemented for OffscreenCanvas. Could we get a +1 from other impl? |
Let's ping @whatwg/canvas once more. |
This is pulling a part of: https://github.com/WICG/canvas-color-space/blob/master/CanvasColorSpaceProposal.md into the spec.
This moves the
convertToBlob
function fromoffscreenCanvas
intocanvas
(andoffscreenCanvas
).@domenic @whatwg/canvas
💥 Error: Wattsi server error 💥
PR Preview failed to build. (Last tried on Jan 15, 2021, 7:58 AM UTC).
More
PR Preview relies on a number of web services to run. There seems to be an issue with the following one:
🚨 Wattsi Server - Wattsi Server is the web service used to build the WHATWG HTML spec.
🔗 Related URL
If you don't have enough information above to solve the error by yourself (or to understand to which web service the error is related to, if any), please file an issue.