Inkscape.org
Tips, Tricks, and Tutorials Understanding and Converting XML User Coordinates
  1. #1
    Chris Copland Chris Copland @isnoone
    *

    PLEASE NOTE: I am using 90 dpi in my Inkscape preferences But as Tyler Points out Below Inkscape Now uses 96dpi. So Check the dpi you are using before calculating.This "TIP" is intended to help users understand the user coordinates used by svg/xml.
    In creating a web  form that asked for the "units to be used" (eg; inches or mm), height, width, number of pages, and weight of paper used,( eg 80gsm), of a book page. I then created a php file to recieve the information and create a svg template for the book cover. in doing so I created a template in inkscape for a 6in x 9in book cover with two rectangles and two lines in the center representing the spine of the book, and a page size larger than the rectangles by a spine width (actualy half a spine width all round just to show the template inside a page for aesthetics).
    However I came across what seemed like a descrepency in my chosen sizes when I tried to use the xml as a guide to write the php.
    Let me use just one of the paths te explain, Below is the 'path' given in when I saved the file as a plain.svg file.
    <path
         style="fill:none;stroke:#ff8888;stroke-width:21.2599;stroke-linecap:square;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
         d="m 659.38086,27.099719 1.16805,841.320031"
         id="path9121" />
    In the stroke-width above you can see that it cleary does not say 6mm which is my required width for a line/path.
    Using that for php would requires calculating what '21.2599' was into mm which would be over cumbersome in codeing.
    So for those of you, like me who have had this issue here is what you have to remember.
    Inkscape uses Rendering of 90dpi (Though you can change this when saving files) 
    Divideing the coordinate by 90    21.2599 / 90 =  0.23622 inches  x 25.4 Gives 6.000mm (Corrected to 4 decimal places)
    Hopefully This will help anyone trying to get a good handle on how and what the XML coordinates in svg are.
    For Engineers, Please remember that for extremely accurate calculation the number of decimal places for a measurement is very important.
    Here is a version of my svg template for you to see what I mean, The sizes used in this are slightly different as I have tweaked them a bit for the php script.
    You can see from the image below that the image represents the back and front cover of a book where the black 0.2mm line sitting inside the pink 6mm line ist the final book size for trimming, the pink area inside the black rectange is the 3mm bleed area that should not include any text that would be effected by the printers trimming and the white area's where the graphics can include book title and blurb.r
    Second Edit Update for those who like formula: See My seperate additional comment below 
    This image is for a 6" x 9" book with 200 pages.

    Template 6X9Book
  2. #2
    Tyler Durden Tyler Durden @TylerDurden
    isnoone

    Inkscape uses Rendering of 90dpi (Though you can change this when saving files) 

    Inkscape default rendering should be 96dpi, since about v0.92.

    https://wiki.inkscape.org/wiki/index.php/Release_notes/0.92#Important_changes

  3. #3
    Chris Copland Chris Copland @isnoone

    Excellent Clarification Thanks for that Tyler. I will edit my post to reflect that I used 90dpi

  4. #4
    Chris Copland Chris Copland @isnoone

    Hi, In my initial TIP I explained that inkscape coordinates are linked to user coordinates and as correctly pointed out by TYler Inkscape uses 96dpi as default. But for those of you who may not be familiar with that
    The user coordinates will be different depending on the dpi set by the creator of the image in a .svg image.
    So to avoid missinforming anyone "I hope" here is how to calculate the user coordinates into mm or inches.
    mm = ( pixels / dpi) x 25.4  This will give you the result as millimeters
    inches = ( pixels / dpi )

    The problem with any other explanation to do with resolution, pixels and dpi. is that a pixel ( The smallest image size that can be displayed ) is made up of three sub pixels and the size of a pixels can be dependant on the resolution of a display. so I agree this does leave everything a bit ambiguous which I hate but since PPI (Pixels Per Inch) can be dependant on the screen resolution this does nothing to clear up the dpi comparison since both PPI and DPI can be different. Just be happy that at least if your using inkscape you control the dpi of your images. here is an image of a pixels showing the three sub pixels.
     

    Pixel Example
  5. #5
    Aero Aero @Aero◻️

    Maybe add a viewBox if you want your measurements to be the same across applications regardless of scale.
    (1dpi and 100dpi sample svg attached)

    Drawing 360 100
    Drawing 360 1
  6. #6
    Chris Copland Chris Copland @isnoone
    *

    Thanks for the Good Tip Aero, For my needs A viewbox is not required Here is a sample of the 6.9 book cover template I used to help me create the svg instructions in the php file.
    I simply then used the variables that were in whatever units the user chose. and substituted them where required in my xml. 

    Sample Rectangle2
Inkscape Inkscape.org Inkscape Forum Tips, Tricks, and Tutorials Understanding and Converting XML User Coordinates