IE support for toDataURL()?

1,424 views
Skip to first unread message

Clinton

unread,
Sep 7, 2007, 4:17:53 PM9/7/07
to google-excanvas
Does ExplorerCanvas support some version of toDataURL() for IE? I need
to be able to pull image data out of a <canvas> and post it to the
server, but I get a method-not-found error when attempting to call
toDataURL() in both IE 6 and 7. If that's not supported, is there
another way I can extract that image data via Javascript? Maybe in
VML? If so, I think I might die and go to coder heaven. Twice. Can
anyone help?

-Clinton

Steve Clay

unread,
Sep 7, 2007, 4:45:06 PM9/7/07
to google-...@googlegroups.com
Clinton wrote:
> Does ExplorerCanvas support some version of toDataURL() for IE? I need
> to be able to pull image data out of a <canvas> and post it to the
> server, but I get a method-not-found error when attempting to call
> toDataURL() in both IE 6 and 7. If that's not supported, is there

Sad to say you're probably out of luck. Firefox's Screengrab extension
[1] used to use Java to grab an area of the screen, but I doubt this can
be done from an unsigned applet in the browser [2]. Also there'd be the
issue of trying to figure *which* area to grab.

[1] http://www.screengrab.org/home/features/implementation/
[2] http://www.brendonwilson.com/projects/signed-java/

--
Steve Clay
http://mrclay.org/

edwar...@gmail.com

unread,
Sep 8, 2007, 11:49:52 AM9/8/07
to google-excanvas

> Sad to say you're probably out of luck. Firefox's Screengrab extension
> [1] used to use Java to grab an area of the screen, but I doubt this can
> be done from an unsigned applet in the browser [2]. Also there'd be the
> issue of trying to figure *which* area to grab.

No, he is talking about the toDataURL function which dumps the canvas
to an image..

http://developer.mozilla.org/en/docs/Code_snippets:Canvas

Firefox does this and he is asking if the exCanvas implementation
supports it..

> Does ExplorerCanvas support some version of toDataURL() for IE? I need
> to be able to pull image data out of a <canvas> and post it to the
> server, but I get a method-not-found error when attempting to call
> toDataURL() in both IE 6 and 7.

I'm not sure but would assume that it is not supported.. Depending on
how simple your canvas drawings are, it should be trivial to send the
canvas data to the server, either as SVG, or convert to SVG on the
server and then run it through an image converter (http://
www.imagemagick.org/) to get a .png or .jpg.. The nice thing about
toDataURL() is that transfer to the server is not needed so you can
allow the user to save the image locally (see mozilla link above), but
in your case the server is the destination anyway..

Hope that helps,

-Ed

Clinton Herget

unread,
Sep 8, 2007, 2:02:29 PM9/8/07
to google-...@googlegroups.com
> Firefox does this and he is asking if the exCanvas implementation
> supports it..

Yes, exactly... it works perfectly in Firefox.

> I'm not sure but would assume that it is not supported.. Depending on
> how simple your canvas drawings are, it should be trivial to send the
> canvas data to the server, either as SVG, or convert to SVG on the
> server and then run it through an image converter (http://

Right, I'm already using ImageMagick on the server side, so it doesn't
matter what format the data gets posted in... PNG, SVG, and VML are
all equally usable. I can even do a check on the client side and use
toDataURL() if the browser is Firefox, or post the SVG/VML data if
it's IE, then let ImageMagick sort it all out. The only missing piece
is, I don't know how to extract the SVG/VML source from the <canvas>
in order to post it... if it's trivial, can you point me in the right
direction for a code snippet? Thanks much.

-Clinton

Steve Clay

unread,
Sep 8, 2007, 4:10:06 AM9/8/07
to google-...@googlegroups.com
edwar...@gmail.com wrote:
> No, he is talking about the toDataURL function which dumps the canvas
> to an image..

Sorry I wasn't clearer, I did know he was referring to toDataURL() but I
missed that he could use VML. excanvas places VML elements inside the
canvas element, so one crude way to serialize them is:

canvasDomElement.innerHTML

Reply all
Reply to author
Forward
0 new messages