Overlaying svg files from the commandline
Hi,
Im trying to create svg files in an automated manner (with unix shell scripts, command line tools, etc.) All output must be in SVG so that I can open the resulting files later in MS Visio and/or LibreOffice.
I figured that one way to achieve this could be : layer existing svg files on top of each other. For example, I might have a (relatively) large svg file that draws a piece of grass or a lawn or something. I then have a (relatively) small svg file that draws a tree. I then draw the tree svg on top of the lawn svg a at a few different places at coordinates x,y. The end result would then be an SVG file of a lawn with some tree's in it.
I was wondering if, and if so how, I could achieve this with Inkscape ? So far Ive only managed to convert a single svg image to another svg image like this :
inkscape ./foo.svg --export-plain-svg=./bar.svg
Is there a way to place small svg files on top of another large svg file, at specified locations in the large svg file, from the commandline, with Inkscape?
Thanks,
Regards,
John Smith
On Fri, 4 Apr 2014 15:22:37 +0200 John Smith <lbalbalba@...155...> wrote:
Hi,
Im trying to create svg files in an automated manner (with unix shell scripts, command line tools, etc.) All output must be in SVG so that I can open the resulting files later in MS Visio and/or LibreOffice.
I figured that one way to achieve this could be : layer existing svg files on top of each other. For example, I might have a (relatively) large svg file that draws a piece of grass or a lawn or something. I then have a (relatively) small svg file that draws a tree. I then draw the tree svg on top of the lawn svg a at a few different places at coordinates x,y. The end result would then be an SVG file of a lawn with some tree's in it.
I was wondering if, and if so how, I could achieve this with Inkscape ? So far Ive only managed to convert a single svg image to another svg image like this :
inkscape ./foo.svg --export-plain-svg=./bar.svg
Is there a way to place small svg files on top of another large svg file, at specified locations in the large svg file, from the commandline, with Inkscape?
Hi John,
I have no idea why you would want to do this at all, and I can't tell you a way to do it *with Inkscape*, but it would be fairly easy to set up an AWK or Python program to go through a bunch of one layer source SVGs, and plunk those layers down on a destination SVG. SVG, after all, is just XML.
If you want to do it the right way, the cool way, the way that gets applause from everyone, use Python with lxml.etree, and do it as an actual XML parsing project. Otherwise, just use break logic to find the starting and ending <layer> and do the whole thing as text.
You could either make a program that takes a layer from one source and appends it to the destination layers, or you could put a loop in that program so it does them all.
I bet if you tell us *why* you want to build an SVG from baby SVGs from the command line, somebody will come up with a much better way of doing it.
SteveT
Steve Litt * http://www.troubleshooters.com/ Troubleshooting Training * Human Performance
On Fri, Apr 4, 2014 at 4:36 PM, Steve Litt <slitt@...2357...> wrote:
I bet if you tell us *why* you want to build an SVG from baby SVGs from the command line, somebody will come up with a much better way of doing it.
Allright, here we go.
I want to create svg files in an automated unattended manner (with unix shell scripts, command line tools, etc.) The output must be a single SVG file, so I can open the resulting files in MS Visio and/or LibreOffice.
The resulting single file should be an SVG that shows (part of) an IT infrastructure. The input is an ascii texty file containing things like hostname, location, etc. The text file has enough content and detail for me to create the picture.
I have no knowledge at all of the svg format or xml in general. So the easiest way to achieve the goal seemed to be to create 'baby svgs' in a WYSIWG GUI application, and then use a commandline program to paste the baby's onto the big canvas. I figured that doing it this way, I could just treat everything as a 'picture' (no matter if its jpg or svg or bmp or whatever) and use a commandline program to cut n paste, and I wouldnt have to learn the internals of SVG or XML.
(I attached an zipped svg file that sort of looks like what I want the end result to be, but im not sure if the mailing list lets me add attachments.)
Regards,
John Smith.
On Fri, 4 Apr 2014 17:27:48 +0200 John Smith <lbalbalba@...155...> wrote:
On Fri, Apr 4, 2014 at 4:36 PM, Steve Litt <slitt@...2357...> wrote:
I bet if you tell us *why* you want to build an SVG from baby SVGs from the command line, somebody will come up with a much better way of doing it.
Allright, here we go.
I want to create svg files in an automated unattended manner (with unix shell scripts, command line tools, etc.) The output must be a single SVG file, so I can open the resulting files in MS Visio and/or LibreOffice.
The resulting single file should be an SVG that shows (part of) an IT infrastructure. The input is an ascii texty file containing things like hostname, location, etc. The text file has enough content and detail for me to create the picture.
I have no knowledge at all of the svg format or xml in general. So the easiest way to achieve the goal seemed to be to create 'baby svgs' in a WYSIWG GUI application, and then use a commandline program to paste the baby's onto the big canvas. I figured that doing it this way, I could just treat everything as a 'picture' (no matter if its jpg or svg or bmp or whatever) and use a commandline program to cut n paste, and I wouldnt have to learn the internals of SVG or XML.
(I attached an zipped svg file that sort of looks like what I want the end result to be, but im not sure if the mailing list lets me add attachments.)
Yes, but you haven't answered the question: Why not just use Inkscape itself to make your grand SVG? How could making a bunch of babies, without simultaneously seeing the first ones, be easier than just building layers in Inkscape, and making them visible/invisible as necessary?
SteveT
Steve Litt * http://www.troubleshooters.com/ Troubleshooting Training * Human Performance
On Sat, Apr 5, 2014 at 7:27 AM, Steve Litt <slitt@...2357...> wrote:
Yes, but you haven't answered the question: Why not just use Inkscape itself to make your grand SVG? How could making a bunch of babies, without simultaneously seeing the first ones, be easier than just building layers in Inkscape, and making them visible/invisible as necessary?
Im sorry, but Im afraid I dont fully understand/follow/grasp what you are trying to tell me here.
So lets assume that the file I attached in the previous mail is my 'grand svg'. I could make that in Inkscape. (in practice, i will be having multiple separate drawings, for example one drawing per subnet). How would I then proceed ? For example, tomorrow host x may be removed from a subnet, and host y may be added. How would I then change the drawing accordingly to reflect those changes from the command line in an automated unattended way ?
Im not sure if making layers visible/invisible would fulfill the requirements, but maybe I just dont understand the concept of layers correctly. Even if I could do that in an automated unattended way from the command line, objects wont always have to be at the same position in the drawing, and the text labels (like a hostname) for the objects will almost always be different.
Thanks for all the help so far,
Regards,
John Smith.
I have tl;dr a bit, but it occurs to me that you need programatic control of a rather intricate visual layout. I would look into Cairo under Python control. You can then output images, pdfs or svgs as needed. You would have control over every last pixel and never have to touch a line of xml.
Hth.
On Sat, Apr 5, 2014 at 10:03 AM, Donn Ingle <donn.ingle@...155...> wrote:
I have tl;dr a bit, but it occurs to me that you need programatic control of a rather intricate visual layout. I would look into Cairo under Python control. You can then output images, pdfs or svgs as needed. You would have control over every last pixel and never have to touch a line of xml.
Hth.
Thanks. I looked at the Cairo website and the examples it has. But that solution requires more programming skills than I have; I might as well spend the time I will need to learn here on understanding xml and the svg format, and then merge the xml/svg files together. ;)
I found something similar with batik, but it looks like that would require me to learn java, so thats not my best bet either. https://xmlgraphics.apache.org/batik/
Thanks,
Regards,
John Smith.
What about using web technologies?
1) Try libraries lie Raphael.js etc. to draw SVG ‘on the canvas’. It would require you, though, to copy the SVG from the source manually. You could even use jQuery’s DOM-manipulation.
or
2) Use PHP to create the SVG files.
or
3) Use HAML to create the SVG files (this should really be pretty easy, and you can try to gradually insert some Ruby for added ‘randomness'
or
4) Use Ruby. But of course, that’s as much a programming language as Java and Python.
Maarten
On 05 Apr 2014, at 10:19, John Smith <lbalbalba@...155...> wrote:
On Sat, Apr 5, 2014 at 10:03 AM, Donn Ingle <donn.ingle@...155...> wrote:
I have tl;dr a bit, but it occurs to me that you need programatic control of a rather intricate visual layout. I would look into Cairo under Python control. You can then output images, pdfs or svgs as needed. You would have control over every last pixel and never have to touch a line of xml.
Hth.
Thanks. I looked at the Cairo website and the examples it has. But that solution requires more programming skills than I have; I might as well spend the time I will need to learn here on understanding xml and the svg format, and then merge the xml/svg files together. ;)
I found something similar with batik, but it looks like that would require me to learn java, so thats not my best bet either. https://xmlgraphics.apache.org/batik/
Thanks,
Regards,
John Smith.
Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
Hi,
IMHO, even if it's totally feasible, it would require a little bit of programming, even to make it "the dirty way" (more on that later).
The open source Graphviz software (http://www.graphviz.org) is more likely to fit your needs, as it auto handles the graphical distribution of the elements based on a list of "connections" so it's very easy to script. There's even a sample of exactly what you're trying to achieve in the gallery (http://www.graphviz.org/Gallery/undirected/networkmap_twopi.html). Granted, it's a very complex network, resulting in a graphical mess ;)
About the dirty way : you could make a program in any language you're comfortable with, this way : 1) open your svg "baby" files (created within Inkscape) with a text editor, cut out everything else than the image itself (at the beginning and end of the files) and save them ("babyfile1.txt"). 2) in two other files ("header.txt" and "footer.txt"), copy / paste the svg preamble and footer, you've just cut from the "baby" files 3) create a program that writes to a text file : a) the content of header.txt b) for each baby image, b1) "<g id="mybabyfilexxx" transform="translate(x position,y position)">" b2) the content of your baby file (babyfile1.txt) b3) "</g>" c) the content of footer.txt
Dirty, messy, bad, shame-on-you, but it can work ;)
Regards, Ed
From: m.h.vandervelde@...155... Date: Sat, 5 Apr 2014 11:02:46 +0200 To: inkscape-user@lists.sourceforge.net Subject: Re: [Inkscape-user] Overlaying svg files from the commandline
What about using web technologies?
- Try libraries lie Raphael.js etc. to draw SVG ‘on the canvas’. It would require you, though, to copy the SVG from the source manually. You could even use jQuery’s DOM-manipulation.
or
- Use PHP to create the SVG files.
or
- Use HAML to create the SVG files (this should really be pretty easy, and you can try to gradually insert some Ruby for added ‘randomness'
or
- Use Ruby. But of course, that’s as much a programming language as Java and Python.
Maarten
On 05 Apr 2014, at 10:19, John Smith <lbalbalba@...155...> wrote:
On Sat, Apr 5, 2014 at 10:03 AM, Donn Ingle <donn.ingle@...155...> wrote:
I have tl;dr a bit, but it occurs to me that you need programatic control of a rather intricate visual layout. I would look into Cairo under Python control. You can then output images, pdfs or svgs as needed. You would have control over every last pixel and never have to touch a line of xml.
Hth.
Thanks. I looked at the Cairo website and the examples it has. But that solution requires more programming skills than I have; I might as well spend the time I will need to learn here on understanding xml and the svg format, and then merge the xml/svg files together. ;)
I found something similar with batik, but it looks like that would require me to learn java, so thats not my best bet either. https://xmlgraphics.apache.org/batik/
Thanks,
Regards,
John Smith.
Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
On Sat, Apr 5, 2014 at 11:02 AM, M.H. van der velde <m.h.vandervelde@...155...> wrote:
- Use HAML to create the SVG files (this should really be pretty easy, and you can try to gradually insert some Ruby for added 'randomness'
Ive briefly looked at the website of HAML, and it looks like that could be the simplest of the solutions you offered. However, I fail to understand how HAMP could be used to create an SVG file ?
Regards,
John Smith.
Another idea is the DOT language. http://www.graphviz.org/doc/info/lang.html
Good for network diagrams with connecting lines. Afaik, it's svgable too.
Hacking svg xml is very technical too, but you can look into clones and perhaps use sed to drop sub drawings into a parent xml shell.
/d
take a look at the blockdiag tool www.blockdiag.com
It has ways of making network diagrams from text files and outputs the result in a few different formats (including svg)
David Lang
On Sat, 5 Apr 2014, Donn Ingle wrote:
Date: Sat, 5 Apr 2014 12:19:06 +0200 From: Donn Ingle <donn.ingle@...155...> Reply-To: Inkscape User Community inkscape-user@lists.sourceforge.net To: Inkscape User Community inkscape-user@lists.sourceforge.net Subject: Re: [Inkscape-user] Overlaying svg files from the commandline
Another idea is the DOT language. http://www.graphviz.org/doc/info/lang.html
Good for network diagrams with connecting lines. Afaik, it's svgable too.
Hacking svg xml is very technical too, but you can look into clones and perhaps use sed to drop sub drawings into a parent xml shell.
/d
On Sat, Apr 5, 2014 at 10:07 PM, David Lang <david@...2429...> wrote:
take a look at the blockdiag tool www.blockdiag.com
It has ways of making network diagrams from text files and outputs the result in a few different formats (including svg)
David Lang
That's actually pretty cool! Im definitely going to play around with that one a little, thanks!
Do you know if its possible to use your own graphics instead of the boxes ? Ive seen at least the addition of a 'network cloud' in an example by using "inet [shape = cloud];", it would be cool if I could replace the boxes with other graphics.
Regards,
John Smith.
On Sat, 5 Apr 2014, John Smith wrote:
On Sat, Apr 5, 2014 at 10:07 PM, David Lang <david@...2429...> wrote:
take a look at the blockdiag tool www.blockdiag.com
It has ways of making network diagrams from text files and outputs the result in a few different formats (including svg)
David Lang
That's actually pretty cool! Im definitely going to play around with that one a little, thanks!
Do you know if its possible to use your own graphics instead of the boxes ? Ive seen at least the addition of a 'network cloud' in an example by using "inet [shape = cloud];", it would be cool if I could replace the boxes with other graphics.
There aren't a lot of shapes defined (there are several), but the code is pretty clean so it shouldn't be hard to add additional shapes. One thing to keep in mind is that all the different varients share a lot of common code, so even if something isn't documented in the network diagram documentation, there are good odds that it will still work.
I actually tried using this to diagram a _very_ complex network (>130 separate networks with >1000 hosts, some multi-homed to as many as 20 different networks), the blockdiag tools spit out a svg for it, but I wasn't able to find a tool that would open the resulting svg :-( the diagram would have been about 20' on each side if printed at the default size.
David Lang
Thank you David, You are right, I'm using windows 7. I forgot about the alt space, and that works perfectly. I can move the file to the center of Windows, but even when I save the file. When I reopen the file, it will again be at the same place off windows. I can live with that but it would be nice if the window would open where it is supposed to open. Do you have any other idea how to fix it? Thank you very much for your answer. Jake
-----Original Message----- From: David Lang [mailto:david@...2429...] Sent: Saturday, April 05, 2014 6:01 PM To: Inkscape User Community Subject: Re: [Inkscape-user] Overlaying svg files from the commandline
On Sat, 5 Apr 2014, John Smith wrote:
On Sat, Apr 5, 2014 at 10:07 PM, David Lang <david@...2429...> wrote:
take a look at the blockdiag tool www.blockdiag.com
It has ways of making network diagrams from text files and outputs the result in a few different formats (including svg)
David Lang
That's actually pretty cool! Im definitely going to play around with that one a little, thanks!
Do you know if its possible to use your own graphics instead of the boxes ? Ive seen at least the addition of a 'network cloud' in an example by using "inet [shape = cloud];", it would be cool if I could replace the boxes with other graphics.
There aren't a lot of shapes defined (there are several), but the code is pretty clean so it shouldn't be hard to add additional shapes. One thing to keep in mind is that all the different varients share a lot of common code, so even if something isn't documented in the network diagram documentation, there are good odds that it will still work.
I actually tried using this to diagram a _very_ complex network (>130 separate networks with >1000 hosts, some multi-homed to as many as 20 different networks), the blockdiag tools spit out a svg for it, but I wasn't able to find a tool that would open the resulting svg :-( the diagram would have been about 20' on each side if printed at the default size.
David Lang
---------------------------------------------------------------------------- -- _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
Ooops I'm sorry, don't know what happened. But it got to the wrong thread J
-----Original Message----- From: Jake Maier [mailto:j.m@...3030...] Sent: Saturday, April 05, 2014 6:30 PM To: 'Inkscape User Community' Subject: Re: [Inkscape-user] Overlaying svg files from the commandline
Thank you David, You are right, I'm using windows 7. I forgot about the alt space, and that works perfectly. I can move the file to the center of Windows, but even when I save the file. When I reopen the file, it will again be at the same place off windows. I can live with that but it would be nice if the window would open where it is supposed to open. Do you have any other idea how to fix it? Thank you very much for your answer. Jake
-----Original Message----- From: David Lang [mailto:david@...2429...] Sent: Saturday, April 05, 2014 6:01 PM To: Inkscape User Community Subject: Re: [Inkscape-user] Overlaying svg files from the commandline
On Sat, 5 Apr 2014, John Smith wrote:
On Sat, Apr 5, 2014 at 10:07 PM, David Lang <david@...2429...> wrote:
take a look at the blockdiag tool www.blockdiag.com
It has ways of making network diagrams from text files and outputs the result in a few different formats (including svg)
David Lang
That's actually pretty cool! Im definitely going to play around with that one a little, thanks!
Do you know if its possible to use your own graphics instead of the boxes ? Ive seen at least the addition of a 'network cloud' in an example by using "inet [shape = cloud];", it would be cool if I could replace the boxes with other graphics.
There aren't a lot of shapes defined (there are several), but the code is pretty clean so it shouldn't be hard to add additional shapes. One thing to keep in mind is that all the different varients share a lot of common code, so even if something isn't documented in the network diagram documentation, there are good odds that it will still work.
I actually tried using this to diagram a _very_ complex network (>130 separate networks with >1000 hosts, some multi-homed to as many as 20 different networks), the blockdiag tools spit out a svg for it, but I wasn't able to find a tool that would open the resulting svg :-( the diagram would have been about 20' on each side if printed at the default size.
David Lang
---------------------------------------------------------------------------- -- _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
---------------------------------------------------------------------------- -- _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
On 2014-04-04 15:22 +0100, John Smith wrote:
Im trying to create svg files in an automated manner (with unix shell scripts, command line tools, etc.) All output must be in SVG so that I can open the resulting files later in MS Visio and/or LibreOffice.
I figured that one way to achieve this could be : layer existing svg files on top of each other. For example, I might have a (relatively) large svg file that draws a piece of grass or a lawn or something. I then have a (relatively) small svg file that draws a tree. I then draw the tree svg on top of the lawn svg a at a few different places at coordinates x,y. The end result would then be an SVG file of a lawn with some tree's in it.
I was wondering if, and if so how, I could achieve this with Inkscape ? So far Ive only managed to convert a single svg image to another svg image like this :
inkscape ./foo.svg --export-plain-svg=./bar.svg
Is there a way to place small svg files on top of another large svg file, at specified locations in the large svg file, from the commandline, with Inkscape?
Maybe useful:
<quote> svg_stack - combine multiple SVG elements into a single SVG element Overview
svg_stack combines multiple SVG elements into a single SVG element. It can be called from the command line (less flexible) or called from the Python interface (more flexible). </quote> https://github.com/astraw/svg_stack
On Sat, Apr 5, 2014 at 12:31 PM, su_v <suv-sf@...16...> wrote:
Maybe useful:
<quote> svg_stack - combine multiple SVG elements into a single SVG element Overview
svg_stack combines multiple SVG elements into a single SVG element. It can be called from the command line (less flexible) or called from the Python interface (more flexible).
</quote> <https://github.com/astraw/svg_stack>
Thanks. on that site I found a reference to 'svg_utils', which seems to be able to do what im looking for. https://github.com/btel/svg_utils
Regards,
John Smith.
participants (8)
-
David Lang
-
Donn Ingle
-
Eddy StEsprit
-
Jake Maier
-
John Smith
-
M.H. van der velde
-
Steve Litt
-
su_v