Convert SVG to MetaPost
![](https://secure.gravatar.com/avatar/9d521f65b27efc7e405e55345585c1fe.jpg?s=120&d=mm&r=g)
Hi all, Is it possible to convert SVG to MetaPost? Currently, I have Bash scripts in my workflow to invoke Inkscape (converting SVG to PDF). I don’t like to allow shell access to TeX. If I can convert SVG to MetaPost, I will gladly Git-track MetaPost files instead of SVG files. That will do away with having to convert SVG into PDF (via Inkscape). Regards Jon
![](https://secure.gravatar.com/avatar/565476157eb3895a9c928ffce26d988d.jpg?s=120&d=mm&r=g)
Hi,
On 12 Aug 2019, at 12:10, Jon Wong
wrote: Hi all,
Is it possible to convert SVG to MetaPost?
Currently, I have Bash scripts in my workflow to invoke Inkscape (converting SVG to PDF). I don’t like to allow shell access to TeX.
If I can convert SVG to MetaPost, I will gladly Git-track MetaPost files instead of SVG files. That will do away with having to convert SVG into PDF (via Inkscape).
SVG (and Inkscape) can do many graphical things that metapost can not do, so I think that would be a bad idea even if there was a tool that could do the conversion for some subset of SVG. That said, SVG is just an XML format, so it should be possible to process simple SVG using ConTeXt’s built-in xml parser (with suitable processing environments, of course). How much work that would entail and whether it is feasible depends on the actual SVG graphics. Best wishes, Taco
![](https://secure.gravatar.com/avatar/46562c7d27388490d62e8d7a5bc960dd.jpg?s=120&d=mm&r=g)
On 8/12/2019 1:15 PM, Taco Hoekwater wrote:
Hi,
On 12 Aug 2019, at 12:10, Jon Wong
wrote: Hi all,
Is it possible to convert SVG to MetaPost?
Currently, I have Bash scripts in my workflow to invoke Inkscape (converting SVG to PDF). I don’t like to allow shell access to TeX.
If I can convert SVG to MetaPost, I will gladly Git-track MetaPost files instead of SVG files. That will do away with having to convert SVG into PDF (via Inkscape).
SVG (and Inkscape) can do many graphical things that metapost can not do, so I think that would be a bad idea even if there was a tool that could do the conversion for some subset of SVG.
That said, SVG is just an XML format, so it should be possible to process simple SVG using ConTeXt’s built-in xml parser (with suitable processing environments, of course). How much work that would entail and whether it is feasible depends on the actual SVG graphics. indeed, and i actually did a partial converter a while ago just to see if it could be done but then decided to delay that till i really need it (normally converting a svg to pdf is quite ok) .. i might pick it up on some cold winternight
Hans ---------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/386a116d129cdc597f2bb6210bbaff7a.jpg?s=120&d=mm&r=g)
On Mon, Aug 12, 2019 at 12:11 PM Jon Wong
Hi all,
Is it possible to convert SVG to MetaPost?
Currently, I have Bash scripts in my workflow to invoke Inkscape (converting SVG to PDF). I don’t like to allow shell access to TeX.
If I can convert SVG to MetaPost, I will gladly Git-track MetaPost files instead of SVG files. That will do away with having to convert SVG into PDF (via Inkscape).
you can check pstoedit http://www.calvina.de/pstoedit/pstoedit.htm it can convert postscript to metapost. So svg->pdf->ps->mp seems to be possible. Of course, I am not sure if it fits in your workflow. -- luigi
![](https://secure.gravatar.com/avatar/9d521f65b27efc7e405e55345585c1fe.jpg?s=120&d=mm&r=g)
Hi Taco! Very enlightening! I’ll just use both MetaPost and SVG for their intended purposes. (SVG will come from workflow involving GIMP/Inkscape; MetaPost for logical, rather than graphical, figures.) Regards Jon
On Aug 12, 2019, at 7:30 PM, luigi scarso
wrote: On Mon, Aug 12, 2019 at 12:11 PM Jon Wong
mailto:jhannwong@gmail.com> wrote: Hi all, Is it possible to convert SVG to MetaPost?
Currently, I have Bash scripts in my workflow to invoke Inkscape (converting SVG to PDF). I don’t like to allow shell access to TeX.
If I can convert SVG to MetaPost, I will gladly Git-track MetaPost files instead of SVG files. That will do away with having to convert SVG into PDF (via Inkscape).
you can check pstoedit http://www.calvina.de/pstoedit/pstoedit.htm http://www.calvina.de/pstoedit/pstoedit.htm
it can convert postscript to metapost. So svg->pdf->ps->mp seems to be possible. Of course, I am not sure if it fits in your workflow.
-- luigi ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________
![](https://secure.gravatar.com/avatar/46562c7d27388490d62e8d7a5bc960dd.jpg?s=120&d=mm&r=g)
On 8/12/2019 1:33 PM, Jon Wong wrote:
Hi Taco!
Very enlightening!
I’ll just use both MetaPost and SVG for their intended purposes. (SVG will come from workflow involving GIMP/Inkscape; MetaPost for logical, rather than graphical, figures.) if you have inkscape installed you can do
\externalfigure[test.svg][width=10cm] and context will handle the conversion ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
participants (4)
-
Hans Hagen
-
Jon Wong
-
luigi scarso
-
Taco Hoekwater