Hi list.
I was wondering if I could perform a batch resize of many small .svg files using Inkscape's command-line arguments? The --help doesn't state much about this, and the only options having to do with size seem to be width and height, or should I use something else like ImageMagik?
I'm on Linux, by the way.
On Thu, 25 Sep 2008 12:18:47 -0500 Gian Paolo Mureddu <thetargos@...155...> wrote:
I was wondering if I could perform a batch resize of many small .svg files using Inkscape's command-line arguments? The --help doesn't state much about this, and the only options having to do with size seem to be width and height, or should I use something else like ImageMagik?
Can you explain a bit more what you're trying to do? Is the desired output .svg files, or .png/.gif/.jpg/whatever?
Cheers -Terry
Terry Brown escribió:
Can you explain a bit more what you're trying to do? Is the desired output .svg files, or .png/.gif/.jpg/whatever?
Cheers -Terry
I'm sorry, I should have been more specific.
I want to batch resize a large number of .svg files _into_ scaled up .svg files, without having to open each individual file, resize and save. Is it possible as command line arguments or through another program like one of ImageMagick?
On Thu, Sep 25, 2008 at 2:53 PM, Gian Paolo Mureddu <thetargos@...155...> wrote:
I want to batch resize a large number of .svg files _into_ scaled up .svg files, without having to open each individual file, resize and save.
That's a bit weird, since SVG is vector it is rarely needed to resize as a whole - you just embed it at a different size, or scale where you imported it, or export it to a higher resolution. The "size" of an SVG is just a hint.
If you really need it, I think it's easiest to do by a XSLT script that would add a transform= attribute to the root svg tag of all files and adjusts width/height. You can also try to do it via Inkscape verbs from commandline, but we don't have a verb which scales to a given extent (verbs cannot have arguments currently).
On Thu, 25 Sep 2008 15:09:55 -0300 "bulia byak" <buliabyak@...155...> wrote:
If you really need it, I think it's easiest to do by a XSLT script that would add a transform= attribute to the root svg tag of all files and adjusts width/height.
I tried just now "add a transform= attribute to the root svg tag" (transform="scale(2.)") and that seemed to have no effect on the file as loaded by inkscape. Changing the width/height attributes of the root svg tag is probably simpler than what I just suggested in the previous post, although not a lot, if you're using xslt.
I'm assuming the poster has some application where they want to import lots of .svg files into an Inkscape project as clipart, and they're all at the wrong size and have to be resized each time which would be annoying.
Of course just changing the scale of the project into which you're importing might be the easiest approach if that's the case.
Cheers -Terry
On Thu, Sep 25, 2008 at 3:22 PM, Terry Brown <terry_n_brown@...12...> wrote:
I tried just now "add a transform= attribute to the root svg tag" (transform="scale(2.)") and that seemed to have no effect on the file as loaded by inkscape.
I might be wrong in saying it's possible, or it may be an Inkscape bug. In any case, it's always possible just to add another level of <g> with transform - it's trivial in XSLT, though a little more difficult in other scripting languages that are not XML-based.
Changing the width/height attributes of the root svg tag is probably simpler than what I just suggested in the previous post, although not a lot, if you're using xslt.
That would just change the canvas size and not scale objects.
Terry Brown escribió:
On Thu, 25 Sep 2008 15:09:55 -0300 "bulia byak" <buliabyak@...155...> wrote:
If you really need it, I think it's easiest to do by a XSLT script that would add a transform= attribute to the root svg tag of all files and adjusts width/height.
I tried just now "add a transform= attribute to the root svg tag" (transform="scale(2.)") and that seemed to have no effect on the file as loaded by inkscape. Changing the width/height attributes of the root svg tag is probably simpler than what I just suggested in the previous post, although not a lot, if you're using xslt.
I'm assuming the poster has some application where they want to import lots of .svg files into an Inkscape project as clipart, and they're all at the wrong size and have to be resized each time which would be annoying.
Of course just changing the scale of the project into which you're importing might be the easiest approach if that's the case.
Cheers -Terry
Actually I'm designing some gliphs to be used as part of a font, the problem is that all the gliphs have to be a separate .svg file to be then imported into FontForge. We ran into a problem where the scale of the .svg's is too small and there's no easy way to resize them in FontForge. We went with .svg rather than bitmap files because they are already vector graphics which can be directly manipulated in FontForge, however we are taking too much time doing the resize of the files, and we don't seem to be able to attain a consistent scale (i.e. all characters of the same/consistent size). Hence rather than opening up each individual gliph (over 180 individual files, thus far), I thought if it could be possible to apply a batch "transform" to change the size of the files "in one pass". That was my original question, rather than a "representation" scale of the SVGs (by a given factor).
On Thu, 25 Sep 2008 12:53:49 -0500 Gian Paolo Mureddu <thetargos@...155...> wrote:
I want to batch resize a large number of .svg files _into_ scaled up .svg files, without having to open each individual file, resize and save. Is it possible as command line arguments or through another program like one of ImageMagick?
The automatically changing the file part is easy enough with a variety of tools like python or xsltproc or others, which are all readily available in linux. The part I'm not sure about is the easiest way to apply a scaling effect to a whole SVG file, that's something that requires more knowledge about SVG structure.
http://www.w3.org/TR/SVG11/coords.html
I think the safest route is something like changing the file from this:
<svg> <metadata/> <defs/> sodipodi:namedview/ <blah1/> <blah2/> <blah3/> </svg>
to:
<svg> <metadata/> <defs/> sodipodi:namedview/ <g transform="scale(2.0)"> <blah1/> <blah2/> <blah3/> </g> </svg>
i.e. grouping all the "content" part of the document and applying a scaling factor to it.
The two possible problems (which might not be problems) are (a) telling the difference between content and non-content (preamble / setup elements) and (b) how this would impact Inkscapes layers. I suspect (b) won't matter for your application and (a) could probably be done by just assuming everything except <metadata/>, <defs/>, and sodipodi:namedview/ is content.
If there's an easier way or a fatal flaw in the above maybe someone can chime in?
Cheers -Terry
On Thu, 25 Sep 2008 12:53:49 -0500 Gian Paolo Mureddu <thetargos@...155...> wrote:
Terry Brown escribió:
Can you explain a bit more what you're trying to do? Is the desired output .svg files, or .png/.gif/.jpg/whatever?
Cheers -Terry
I'm sorry, I should have been more specific.
I want to batch resize a large number of .svg files _into_ scaled up .svg files, without having to open each individual file, resize and save. Is it possible as command line arguments or through another program like one of ImageMagick?
I haven't tested it very hard but the attached bigger.xsl (XSLT) script seems to work. Invocation is something like:
xsltproc --stringparam scale 2.5 bigger.xsl in.svg >out.svg
or for all the .svg files in the current directory:
for i in *.svg; do xsltproc --stringparam scale 2.5 bigger.xsl $i
bigger_$i; done
(all on one line)
If you want to make things smaller use a scale value smaller than 1.0
If your system doesn't have xsltproc, then for Ubuntu at least run:
sudo apt-get install xsltproc
Hope that helps, Cheers -Terry
Hi Gian Paolo,
SVG files are scalable if they are exported correctly. The problem is that Inkscape (like many other drawing apps (Corel, Illustrator, etc.) works "paper-oriented" and not "screen oriented".
In a proper screen oriented SVG you would use the following root element, which scales nicely and automatically in any browser:
<svg width="100%" height="100%" viewBox="0 0 1024 768"> <!-- use your own paper size in the viewbox; some content --> </svg>
So I suggest you pull out the absolute width and height values that Inkscape produces and write them to the viewBox attribute.
Inkscape should have an option for this, something like "Publish SVG for the Web". It is very simple to do.
Hope this helps, Andreas
Gian Paolo Mureddu wrote:
Hi list.
I was wondering if I could perform a batch resize of many small .svg files using Inkscape's command-line arguments? The --help doesn't state much about this, and the only options having to do with size seem to be width and height, or should I use something else like ImageMagik?
I'm on Linux, by the way.
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
participants (4)
-
Andreas Neumann
-
bulia byak
-
Gian Paolo Mureddu
-
Terry Brown