Export to SVG - object sizes not correct?

Post questions on how to use or achieve an effect in Inkscape.
markww

Export to SVG - object sizes not correct?

Postby markww » Tue Nov 25, 2008 2:41 pm

Hi,

As a test, I create a rectangle object. I make its width and height 200. I set its x,y origin to 0,0. When I export the object as a plain SVG file, I get curious values for the object in the output SVG file:

Code: Select all

<svg
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   version="1.0"
   width="200"
   height="200"
   id="svg2459">
  <defs
     id="defs2461" />
  <g
     transform="translate(0,-852.3622)"
     id="layer1">
    <rect
       width="190.0341"
       height="190.0341"
       x="4.9829493"
       y="857.34515"
       id="rect2469"
       style="opacity:1;fill:#ff2a2a;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:9.96589851;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
  </g>
</svg>


Why is the rect definition not 200x200, instead it is ~190 x ~190? Also, why does the layer have such a strange y-transform? Why do the x and y values not sit directly at 0,0? I may be using the application wrong, but inside Inkscape my square says it's at 0,0 of size 200,200.

Thanks for any info,
Mark

markww

Re: Export to SVG - object sizes not correct?

Postby markww » Tue Nov 25, 2008 4:15 pm

So I downloaded Adobe Illustrator to see how they export shapes to SVG format. They will internally flip their y-coordinates for you, which is good, but more importantly, their exports don't have this strange size change between what you see in the application, and what you see in the exported SVG file.

I sort of get the transformation injection now though (in Inkscape), it will happen as soon as you move your shape away from where you first created it. So unless you create your shape directly at the origin, you're going to have those transformations appended to your shape. So I guess if anyone knows how to force Inkscape to create a shape about the origin, that'll solve at least one problem for me,

Thanks

Simarilius
Posts: 626
Joined: Wed Jun 06, 2007 2:37 am

Re: Export to SVG - object sizes not correct?

Postby Simarilius » Tue Nov 25, 2008 10:09 pm

The width and height boxes define the object width+height including stroke. The xml width and height are to the stroke centreline, so if you have a 10 pixel stroke and want a 200 wide box, it needs to be 190 in the xml. (190 +5 on left +5 on right)
I notice your canvas has a size of 200,200 did you use the doc prefs bit ti make it fit the object? if so thats where the transform came from. when you resized the canvas it essentially moved the origin, so the transform on the group was added to correct for it. You'll notice that its the opposite of the x,y co-ords of the rect....


Return to “Help with using Inkscape”