W3C home > Mailing lists > Public > whatwg@whatwg.org > April 2011

[whatwg] Proposing <canvas>.toBlob(contentType)

From: Juriy Zaytsev <kangax@gmail.com>
Date: Wed, 13 Apr 2011 18:36:31 -0400
Message-ID: <BANLkTinXKoRxDuX7rrpJvHJS9fnKNgsLQA@mail.gmail.com>
I would be in favor of this.

In my recent app ? http://mustachified.com ? I used `mozGetAsFile` to
retrieve file from canvas, append it to form data and send to an external
service via cross-domain request.

When mozGetAsFile was not available, I had to build blob manually from
canvas' data url. Aside from the fact that it's more code to
transfer/maintain, and (likely) worse performance, the blob building also
relies on presence of BlobBuilder, ArrayBuffer and Uint8Array ? so is not
always available.

Source: http://mustachified.com/master.js

-- 
kangax

On Wed, Apr 13, 2011 at 6:02 PM, Kyle Huey <me at kylehuey.com> wrote:

> Hello All,
>
> Gecko 2.0 ships with a non-standard method on <canvas> named
> mozGetAsFile(contentType, fileName).  We added this for internal use in our
> UI.  It retrieves the contents of the canvas as a File object (at the time
> Gecko did not supports Blobs) encoded in the contentType according to the
> same rules toDataURL uses.
>
> I propose adding a toBlob(contentType) method to the canvas element in the
> style of toDataURL.  This would greatly increase the options available to
> developers for extracting data from a canvas element (a Blob can be saved
> to
> disk, XHRed, etc.)
>
> - Kyle
>
Received on Wednesday, 13 April 2011 15:36:31 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:48:03 GMT