[whatwg] canvas, img, file api and blobs

On Mon, Feb 15, 2010 at 11:47 PM, Maciej Stachowiak <mjs at apple.com> wrote:
>
> On Feb 15, 2010, at 1:53 PM, Jonas Sicking wrote:
>
>> On Mon, Feb 15, 2010 at 6:43 AM, Stef Epardaud <stef at epardaud.fr> 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.

Absolutely! I definitely agree that we need a type like this. The
sooner the better. On that note, do you know what the latest status is
within ECMA on this? I know you made a proposal on the webapps list
(or was it here?), did that go anywhere?

However I suspect it'd be useful to be able to extract as Blob object
as well, for storing in places like databases or to extract a url.

/ Jonas

/ Jonas

Received on Tuesday, 16 February 2010 00:13:11 UTC