I was wondering if anyone had managed exporting .svg files to TikZ code. I do not mean include an .svg file into a latex document, but rather to obtain the code of an image so you can then edit it with TikZ.
I know that this has been done here: http://www.texample.net/tikz/examples/india-map/ using inkscape and the svg converter svg2tikz
(https://github.com/kjellmf/svg2tikz) but I cannot reproduce it after installing inkscape.
When I run inkscape, I get the following message on the console (I run it from the console):
(inkscape:8700): Gtk-CRITICAL **: gtk_misc_set_alignment: assertion `GTK_IS_MISC (misc)' failed
I can still import an image and export to TikZ path but I get the following error message in a pop-up window:
Inkscape encountered an internal error and will close now.
Automatic backups of unsaved documents were done to the following locations:
/home/squeeze/New document 1.2012_06_19_18_10_24.0.svg
and the exported .tex file shows the following code which does not reproduce the image and compiles to a blank page:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[y=0.80pt,x=0.80pt,yscale=-1, inner sep=0pt, outer sep=0pt]
\begin{scope}[cm={{2.4087301,0.0,0.0,3.1036527,(-508.27381,-1163.9469)}}]
\begin{scope}[cm={{1.25,0.0,0.0,-1.25,(213.2835,636.20725)}}]
\begin{scope}[scale=0.100]
\begin{scope}[cm={{2304.0,0.0,0.0,1195.2,(141.732,141.732)}}]
\end{scope}
\end{scope}
\end{scope}
\end{scope}
\end{tikzpicture}
\end{document}
Has anyone done it?
I run Debian Squeeze; Inkscape is 0.47 and the forum on the inkscape-svg converter is not really active so I thought someone may have done it here.
I do not wish to specifically use .svg; I use GIMP usually, so if there is such a way to do it in GIMP, I am happy to do it (even better).
Here is an example of an .svg
image that fails the above procedure:
Best Answer
The problem is that your source image is a bitmap (raster image), while TikZ is a vector graphics format. In order to export your bitmap image to TikZ you have to convert it to a vector format first. This process is called "tracing" or "vectorization".
Tracing can be done in numerous ways:
Shift+Alt+B
to open the tracing dialogue. Twiddle with the knobs or just press "Ok". Then delete the bitmap.Once you have a vectorized version of your image, converting it to TikZ with any svg-to-TikZ converter (like svg2tikz) should be possible.