views:

89

answers:

3

can we export canvas image as svg or base 64 and then import it back again?

A: 

hi you should try this one this one

yosanu
+1  A: 

It's not easy, no. There is no direct method to export Canvas graphics to SVG - they are fundamentally different types of representation, Canvas 2D uses a raster display, like television images, and SVG stores the geometric shapes, which can be resized without degradation of quality.

The simple answer is if you need SVG output, don't use canvas, start with SVG (the simpler SVG graphics library http://raphaeljs.com/ might be useful here).

The complex answer is - you could export to SVG if you record all the canvas operations you perform and have some way to recreate them with SVG, but, unless you have a restricted set of operations, that basically means you need to implement all canvas drawing functions and modes!

andrewmu
A: 

andrewmu gets a well-deserved point from me for the great answer to the question in its original form.

The amended question ("or base64") is easy to Google: canvas.toDataURL().

Nickolay