[whatwg] canvas, img, file api and blobs

Stef Epardaud stef at epardaud.fr
Mon Feb 15 06:43:39 PST 2010


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.

In many cases it is useful to resize images on the client so that upload
size can be limited (to save bandwidth) and uploading in base64 would
mitigate this.

In a related question, is there any guarantee that when we draw an image
with EXIF information into a canvas for resizing, we get (or not) the
EXIF back in the resized image (currently via toDataURL())?

Stéphane Epardaud

More information about the whatwg mailing list