On Feb 15, 2010, at 1:53 PM, Jonas Sicking wrote:
On Mon, Feb 15, 2010 at 6:43 AM, Stef Epardaud <[email protected]>
wrote:
Hello,
I am trying to write a client-side application in HTML5 that resizes
images before uploading them to the server. I saw several demos
that did
this resizing using canvas and img, but I have only seen how to get a
data URL out of a canvas, and since Base64 is about 1.37% larger than
the equivalent binary data (according to http://en.wikipedia.org/wiki/Base64
),
I wonder why it is not possible to get a Blob out of the canvas?
Especially since the File API supports uploading Blobs.
It has been suggested earlier on this list that we add a
canvas.toFile
or
canvas.toBlob
function, which would return a binary Blob instead of a data URL. For
exactly the reasons that you mention. I hope to write a test
implementation of this for firefox in the near future.
I still think we need a type for binary data that can represent in-
memory resources. Blobs only allow asynchronous access, since they are
meant to represent something like a file, a slice of a file, or a
chunk of data in an on-disk database. It doesn't make sense to use
such an inconvenient interface to pull out the contents of the canvas,
which pretty much have to already be in memory.
Even something like WebGL's typed arrays would be better, if the
ECMAScript committee doesn't come up with a good solution for basic
binary data soon.
Regards,
Macie