Contact emails
Spec
https://html.spec.whatwg.org/multipage/scripting.html#dom-canvas-toblob
Summary
Creates a Blob object representing a file containing the image in the canvas, and invokes a callback with a handle to that object. Currently, we support three types of image formats--PNG, JPEG and WEBP--just like what toDataURL does. If the file type is not specified, default image format is "image/png".
Link to “Intent to Implement” blink-dev discussion
Is this feature supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes.
Demo link
No demos. But at this moment, developers can turn on experimental canvas features flag in browser to try the feature.
Debuggability
This feature does not require special debugging support on its own.
Interoperability and Compatibility Risk
Interoperability risk is low, as other browsers have already supported this function. Firefox has released this feature in version 19 (https://developer.mozilla.org/en-US/Firefox/Releases/19) and Internet Explorer has the same feature (supporting only PNG image format) with vendor-prefixed name (https://msdn.microsoft.com/en-us/library/windows/apps/hh465735.aspx). Other browsers have no public signals yet.
Compatibility risk is low, as this does not remove or change existing features.
OWP launch tracking bug
Entry on the feature dashboard
https://www.chromestatus.com/features/4562033294966784
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
Comparing this to Gecko's IDL, I noticed that their callback is not nullable. That makes much more sense, so I've fixed the spec: https://github.com/whatwg/html/pull/377
It's really unfortunate this this API doesn't use promises, but it was added to the spec in 2011, so it is what it is.
On 4 December 2015 at 00:59, Philip Jägenstedt <phi...@opera.com> wrote:Comparing this to Gecko's IDL, I noticed that their callback is not nullable. That makes much more sense, so I've fixed the spec: https://github.com/whatwg/html/pull/377What does Gekco do with <canvas>.toBlob(42) btw ? The first argument could be anything. The spec algorithm steps say.6. If callback is null, abort these steps.
It's really unfortunate this this API doesn't use promises, but it was added to the spec in 2011, so it is what it is.Olivia already mentioned (in bug) that promise based API version is planned.
I don’t understand our shipping strategy here with respect to promises vs. callbacks.
As Philip mentioned, the callback version exists only as a legacy, and the promise version is the future.
But why even implement the callback version at all? It is implemented (unprefixed) in one browser. Developers cannot write cross-browser code using toBlob(callback) today. That surely doesn’t make it a part of the web platform that we want to support.
We should instead take this opportunity to implement only the promise version. Maybe with a different name, if we are worried about Gecko compatibility, since apparently they don’t implement the promise version yet (looking at https://mxr.mozilla.org/mozilla-central/source/dom/webidl/HTMLCanvasElement.webidl).
I don’t think we should ship the current implementation.
I find the distinction between Blob and File in the spec to be sloppy and potentially a source of interop issues, so I filed this spec issue. But that doesn't need to block shipping.
interface File : Blob { ... }
On Thu, Dec 3, 2015 at 4:30 PM, Noel Gordon <no...@chromium.org> wrote:On 4 December 2015 at 01:38, Rick Byers <rby...@chromium.org> wrote:I find the distinction between Blob and File in the spec to be sloppy and potentially a source of interop issues, so I filed this spec issue. But that doesn't need to block shipping.void toBlob(FileCallback? _callback, optional DOMString type, any... arguments);
The FileCallback confused me when we wrote it. Why not BlobCallback? I recall the answer was along the lines of ... "because it's not needed since, due of this relationshipinterface File : Blob { ... }
a FileCallback happily accepts a Blob argument."I assumed Hixie knew what he was talking about, and I quibbled no more.For compat, I think we should should be returning a Blob.
I don’t understand our shipping strategy here with respect to promises vs. callbacks.
As Philip mentioned, the callback version exists only as a legacy, and the promise version is the future.
But why even implement the callback version at all? It is implemented (unprefixed) in one browser. Developers cannot write cross-browser code using toBlob(callback) today. That surely doesn’t make it a part of the web platform that we want to support.
We should instead take this opportunity to implement only the promise version. Maybe with a different name, if we are worried about Gecko compatibility, since apparently they don’t implement the promise version yet (looking at https://mxr.mozilla.org/mozilla-central/source/dom/webidl/HTMLCanvasElement.webidl).
I don’t think we should ship the current implementation.
On Thu, Dec 3, 2015 at 10:11 AM, Domenic Denicola <d...@domenic.me> wrote:I don’t understand our shipping strategy here with respect to promises vs. callbacks.
As Philip mentioned, the callback version exists only as a legacy, and the promise version is the future.
But why even implement the callback version at all? It is implemented (unprefixed) in one browser. Developers cannot write cross-browser code using toBlob(callback) today. That surely doesn’t make it a part of the web platform that we want to support.
We should instead take this opportunity to implement only the promise version. Maybe with a different name, if we are worried about Gecko compatibility, since apparently they don’t implement the promise version yet (looking at https://mxr.mozilla.org/mozilla-central/source/dom/webidl/HTMLCanvasElement.webidl).
I don’t think we should ship the current implementation.
I think there's a good debate to be had here, but I wouldn't want to block this intent-to-ship for long on this ("intent to implement" would have been a much better time for this debate). If someone wants to get a promise-based version added to the spec ASAP, and if Mozilla shows interest in implementing it sometime soon, then I'd personally support shipping only the promise based API and not the legacy callback-based API. Otherwise I'm fine getting caught up to Mozilla first by shipping the existing API, and worrying about adding a promised based API as a follow-up step.
-Boris
-Boris