getting height and width of inkscape objects on commandline

Post questions on how to use or achieve an effect in Inkscape.
psytoolkit
Posts: 2
Joined: Sun Nov 13, 2011 2:55 am

getting height and width of inkscape objects on commandline

Postby psytoolkit » Sun Nov 13, 2011 3:08 am

I use inkscape Inkscape 0.48.2 r9819 (Jul 11 2011) on Ubuntu 11.10 (64bit).

My goal is to get the horizontal, vertical position and height and width of all objects in my inkscape file.
I want to extract this information on the command line.
As instructed on the man page, I use the command line option, and I do not want to use the GUI (so I use -z)

It works, but I do not get the answers in pixels, instead it is another unit (not sure which, maybe millimeters).

For example:

If I use
inkscape -z -S myfile.svg

I get:

svg2,83.785713,68.071414,112.42857,102.42858
layer1,83.785713,68.071414,112.42857,102.42858
stimulus1,83.785713,68.071414,36.714287,36.714287
stimulus2,159.5,133.78571,36.714287,36.714287


this is a comma separated list, a line for each object. All fine, just not in pixels as unit.
Is there a way to get this done. I have tried setting the default units to px in my document settings.

Thanks for any help.

PatJr
Posts: 81
Joined: Fri Jul 29, 2011 5:35 am

Re: getting height and width of inkscape objects on commandl

Postby PatJr » Sun Nov 13, 2011 5:58 am

dunno
I would try a very simple object with a know value,1 x 1 box ? and then see if I could interpolate the units that inkscape is using
I think some question about scaling in inkscape came up a while back and I believe the internal units are in pixels?

be sure to post back what you find out
Pat Jr.

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: getting height and width of inkscape objects on commandl

Postby ~suv » Sun Nov 13, 2011 10:35 am

psytoolkit wrote:It works, but I do not get the answers in pixels, instead it is another unit (not sure which, maybe millimeters).
The results are in pixels (aka SVG user units).

Could you explain how you verify the results and conclude that the units in your test case are not pixels (aka SVG units)?

(Note that the returned x and y coordinates are relative to the SVG coordinate system (which differs from the rulers as seen in the GUI): the SVG coordinate system has the origin in the upper left corner of the page, with the y-axis pointing down, whereas in Inskcape's GUI, the origin is in the lower left corner of the page, with the y-axis pointing upwards.)

psytoolkit
Posts: 2
Joined: Sun Nov 13, 2011 2:55 am

Re: getting height and width of inkscape objects on commandl

Postby psytoolkit » Mon Nov 14, 2011 1:31 am

Thanks to all for the quick replies :D . You are right, the units are in pixels. And you are right that
the coordinate system of the GUI and the "inkscape -S"-coordinate system have different
origins.

I am still trying to figure out 2 things:

1) Can we get "query" the document size in pixels?

2) What is the object ID "svg2" exactly (which is created in any new document).


Return to “Help with using Inkscape”