Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
Kunda1
Posts: 5485
Joined: Thu Jan 05, 2017 9:03 pm

Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Postby Kunda1 » Mon Jun 17, 2019 2:57 pm

issue #3420 - SVG imports from inkscape lead to wrong dimensions
Bug was first isolated thanks to the german FreeCAD contingent ;) in https://forum.freecadweb.org/viewtopic.php?f=13&t=27344
With the change from 0.91 to 0.92 inkscape devs changed the conversion factor of userunit (uu) and mm. Pre-0.92 it was 1uu=1 inch/90 and starting from 0.92 it is 1 uu=1inch/96. This was necessary to meet the actual recommendations/rules of svg-standard and css. See article in inkscapewiki for further reading.

When a user creates a file in inkscape with absolute dimensions (mm) and saves it, then imports it into FC, bodies in Freecad come out with too large dimensions. For example - a 100mm square will be 106,66mm in FC now (100 x 96/90).
Example SVGs are available in the ticket
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
Kunda1
Posts: 5485
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Postby Kunda1 » Fri Jun 28, 2019 10:41 am

Will there be a need to make an import pop-up asking if the user wants pre-Inkscape0.92 or post-Inkscape0.92 compatibility?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
PrzemoF
Posts: 2649
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Postby PrzemoF » Fri Jun 28, 2019 12:57 pm

Maybe we could use the version stored in the actual SVG file?

Code: Select all

inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
chrisb
Posts: 18038
Joined: Tue Mar 17, 2015 9:14 am

Re: Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Postby chrisb » Fri Jun 28, 2019 2:32 pm

Kunda1 wrote:
Fri Jun 28, 2019 10:41 am
Will there be a need to make an import pop-up asking if the user wants pre-Inkscape0.92 or post-Inkscape0.92 compatibility?
No, I don't think so. It is all going to the newer versions, in FreeCAD as well as in Inkscape. When 0.19 becomes stable even more people use newer inkscapes, probably 1.0.
User avatar
Kunda1
Posts: 5485
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Postby Kunda1 » Wed Jul 03, 2019 2:34 pm

PrzemoF wrote:
Fri Jun 28, 2019 12:57 pm
Maybe we could use the version stored in the actual SVG file?

Code: Select all

inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
Hey @PrzemoF, would you mind elaborating how that could be useful?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
PrzemoF
Posts: 2649
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Postby PrzemoF » Wed Jul 03, 2019 4:48 pm

I hope I don't miss something obvious :D
- in inkscape up to Pre-0.92 it was 1 uu=1 inch/90
- in inkscape starting from 0.92 it is 1 uu=1 inch/96
- SVG file created by inkscape contains a line like this:

Code: Select all

inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
So by checking the version of inkscape that saved the actual SVG file you can tell what should the conversion factor.
openBrain
Posts: 1959
Joined: Fri Nov 09, 2018 5:38 pm

Re: Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Postby openBrain » Wed Jul 03, 2019 5:20 pm

Given that the second (96 DPI) should be the standard. :P
Actually maybe a better algorithm is "SVG is 96 DPI except for Inkscape < 0.92 where it's 90 DPI". ;)
Hope this is the current behavior. :)
User avatar
Kunda1
Posts: 5485
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Postby Kunda1 » Thu Jul 04, 2019 10:45 pm

Hey @wandererfan, could you weigh in on this? How are we evaluating SVG's currently ?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
wandererfan
Posts: 2968
Joined: Tue Nov 06, 2012 5:42 pm

Re: Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Postby wandererfan » Fri Jul 05, 2019 12:39 am

Kunda1 wrote:
Thu Jul 04, 2019 10:45 pm
Hey @wandererfan, could you weigh in on this? How are we evaluating SVG's currently ?
Geometry imports are done by Draft.importSVG.py and it has 90 ppi hard coded in a number of places.

Drawing and TD don't seem to consider ppi at all, just user units.
User avatar
Kunda1
Posts: 5485
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Postby Kunda1 » Fri Jul 05, 2019 9:05 pm

Looks like it's in the getsize() function: https://github.com/FreeCAD/FreeCAD/blob ... VG.py#L263
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features