command line: how to get correct y coordinate and height of doc (not drawing) of an existing svg?
Scripting inkscape
Using the command line, how can I get the correct y-coordinate and height of doc (not drawing) of an existing svg?
I fetch the coordinates of all paths in the image with
inkscape --without-gui --query-all $svgfile | grep path
(1)
Then I do something with selected paths in $svgfile.
Then I export a small area containing the path I am interested in
inkscape --file=p072.svg --export-dpi=300 --without-gui --export-
The y coordinate is I get from command (1) is wrong. The origin is false. i have to correct it with the document height. How can I get it from the command line? I am not interested in the --query-height option. It gets the height of the drawing, not the document.
See the kludge I have found for my problem:
sub get_all_path_coords {
my ($svgfile ) = @_;
#The --query-* command line parameters now return the true SVG bounding box of the object
#instead of the Inkscape coordinate system bbox (with inverted Y axis).
#The new behavior makes more sense for scripting use of Inkscape
my @lines = `inkscape --without-gui -S $svgfile | grep path`;
# expample:
#path730,
my %pathcoords = ();
my $dx = 2.3;
my $dy = 1.65;
foreach my $p (@lines){
chomp $p;
my @c = split /,/, $p; # decimal sep = comma
my $path = shift @c;
my @cdot = map { $_} @c;
$cdot[0] = $c[0] + $dx;
$cdot[2] = $c[2] - 2 * $dx;
$cdot[1] = 1030.5 - $c[1] - $dy;
$cdot[3] = $c[3] + $dy;
$pathcoords{
}
return \%pathcoords;
}
I have found by working with the gui that the document height is 1030.5 , --query--height gives 835 or so. then I subtract a few pixels for some reason .
There must be a better way to get the correct y coordinate that I can pass to --export-area
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Inkscape Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- knb
- Solved:
- Last query:
- Last reply: