jheinen / GR.jl

Plotting for Julia based on GR, a framework for visualisation applications
Other
357 stars 76 forks source link

SVG --> CGM. #54

Closed ma-laforge closed 6 years ago

ma-laforge commented 7 years ago

I noticed GR supports SVG output - but I cannot tell if it can read in SVG drawings and render it on the GR backend.

I ask because GR seems to have all the parts necessary to convert SVG files to CGM (It might even be an ideal backend for a "vector" image converter).

Though SVG is supposed to be widely supported, CGM is actually better supported in many cases (even within MS applications).

jheinen commented 7 years ago

GR does not support SVG input. You can export graphics (begingraphics/endgraphics) to XML formatted files:

using GR
begingraphics("ex.gr")
histogram(randn(10000), title="\$\\textrm{Histogram : }\\sigma = \\sqrt {\\mu_2 }\$")
endgraphics()

... and import them using importgraphics, probably in another GR session:

using GR
importgraphics("ex.gr")

Right now, SVG is the preferred format for post-processing, e.g. by programs like inkscape.

I'm not very familiar with Windows applications - I used GR's WMF output format some time ago.

Which MS application(s) are you using to read CGM files? I'm asking because I can't guarantee that this driver is up-to-date.

lobingera commented 7 years ago

I just looked into current powerpoint (MS Office 365 ProPlus) picture import, CGM isn't there, eps, wmf and emf are.

Inkscape (which can be used also as converter on the commandline, so for scripting) can export all the three. For julia-only solution someone might use https://github.com/lobingera/Rsvg.jl and paint to a EPS surface if svg to other vector conversion is needed.

ma-laforge commented 7 years ago

Right now, SVG is the preferred format for post-processing, e.g. by programs like inkscape.

Yes, but I find many applications are still behind in supporting SVG.

I'm not very familiar with Windows applications - I used GR's WMF output format some time ago.

I did not know GR had a WMF output. I will have to try that.

@jheinen: Which MS application(s) are you using to read CGM files? I'm asking because I can't guarantee that this driver is up-to-date.

@lobingera: I just looked into current powerpoint (MS Office 365 ProPlus) picture import, CGM isn't there, eps, wmf and emf are.

I used to integrate CGM drawings into Word - but I feel a bit stupid now. It appears many applications have either dropped or reduced CGM support in their applications. I am no longer sure CGM still has value in modern programs. Very sad: I am quite dissapointed with how poorly modern applications support "vector" graphics. I am also very dissapointed in the quality/robustness of conversion tools.

ma-laforge commented 7 years ago

@lobingera: Maybe Inkscape or Rsvg would indeed be a better option for conversion.

ma-laforge commented 7 years ago

NOTE: I tried loading GR's cleartext CGM output in Inkscape. It failed.

Apparently there are multiple variants of CGM (including binary encoding).

Again, maybe CGM support is no longer supported sufficiently for me to pursue this.

jheinen commented 7 years ago

@ma-laforge : You are right - we all had this (many years ago). It's alarming that modern tools often only support subsets of a given technology, e.g. vector graphics. I'll probably add the good old cgmviewer to GR again, which was part of its predecessor (gli).

I'll also take a closer look at @lobingera Rsvg library - although I'd prefer to import SVG without any dependancy to a specific graphics library (like cairographics).

lobingera commented 7 years ago

@jheinen librsvg is part of the freedesktop/GNOME zoo and has actually quite low number of dependencies. Still, you will need libcairo, libgobject and similar (incl. libxml2).

But doing svg input with a xml parser only and try to implement the svg rendering model locally, good luck. This is one of the more complicated things you can do in graphics.