views:

173

answers:

3

I am wondering if it is possible to get a url to some image on google, say a square (jpg/png/gif), and process it into an SVG. Is this possible?

Right now I'm getting ByteArray data in Actionscript by making a URLRequest('image/on/google'), with dataFormat="binary". I don't think Actionscript could handle/do it, but maybe it could. I'm also good with Ruby, so perhaps is this possible with Ruby?

If so, any sample code/libraries to get started?

I guess another way to ask it is, how do I convert a Bitmap to a set of Vector Paths like Adobe Illustrator does?

+1  A: 

You need to vectorise it, which is often called 'tracing'. Desktop illustrating programs like Adobe Illustrator can do this, by clicking around in the UI obviously.

There are free libraries and tools like potrace and Autotrace which do take (grayscale) bitmaps and generate SVG.

Commercial tools like Vector Magic can do colour images too.

Will
I believe potrace can handle only black and white images - I might be wrong, it was a while ago that I checked it.
Amarghosh
Hmm, its an interesting problem. All I need - another hobby project idea! :/
Will
+1  A: 

There is no default support - You'll have to write your own raster-to-vector conversion algorithm, preferably at the server side as it can be CPU heavy. A quick search for raster to vector / jpg to svg revealed only tools and algorithms, not APIs.

Amarghosh
the tool link is to an embedder, not a converter, surely?
Will
I didn't test it at first - it seems to just embed the raster image in an svg.
Amarghosh
A: 

Have a look at Sakri's bitmap to polygon code: http://www.sakri.net/blog/2009/06/12/an-approach-to-triangulating-polygons-with-holes/

Quasimondo