SVG and DPI, absolute units and user units: Inkscape vs. Firefox vs. ImageMagick

All dimensions in a path tag are in user units.

You cannot specify absolute units within a path tag, which is why the path in the middle square does not render.

The simplest way I have found is to set the units using viewbox:

  • Set the width & height in inches.
  • Then set the viewbox to be the same.
  • This sets the user unit to be one inch.
  • All sizes are then specified in inches (note: I used lower case l in path tag to specify a relative move)

This displays correctly in Inkscape and Firefox.

<svg
    xmlns:svg="http://www.w3.org/2000/svg"
    xmlns="http://www.w3.org/2000/svg"
    version="1.1"
    width="8in"
    height="4in"
    viewBox="0 0 8 4">

    <g transform="translate(4,0.5)">
        <rect
            width="1.111"
            height="1.111"
            x="0.1111"
            y="0.1111" />
        <path d="M 0.1111,0.1111 l 1.111 1.111" style="stroke: #ff0000;stroke-width:0.01"  />
    </g>
</svg>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)