SVG Importer Selectable DPI
Although SVG images are vectors that can be scaled to any size, many programs allow you to specify that the viewbox be specific linear dimensions. It just does the math for you between its unitless values and the number of such units it thinks fits in that real-world size.
Unfortunately different programs do this slightly differently. Those that originated on Mac assume a DPI of 72, while programs that started out on Windows will assume a DPI of 96.
As an example you can use Illustrator to make an SVG that contains a box that is exactly 20 centimeters wide. When you import the resulting SVG into Blender it will be 16 centimeters wide because our importer uses 90 as the base DPI while Illustrator assumed 72 when exporting. It will also be incorrect if you do the same thing from Inkscape because that program uses 96 DPI.
The solution to this is to just have a selectable DPI in the properties of the importer. It could contain "90" to match current behavior, but also add the more common "72" and "96".
This change could be done with only knowledge of Python and how Blender importers work. That DPI value is the "72" you will find on lines 1821 and 1822 of import_svg.py in blender\scripts\addons\io_curve_svg
5 Comments
In our studio we often import SVG drawings that was converted from PDF and also use custom SVG addon that writes SVG from selected geometry to edit it in Inkscape and import back in Blender-inkscape-Blender pipeline (for example, general plans)
The ability to have DPI correspondance or at least the ability to set SVG import scale factor is a very desirable functionality to us, because imported SVGs are always very small.
How is the user to know what dpi was used by the software that exported it?
If they don't know they could keep it on the default DPI, which could be 90 as it is now. But the other list items could possibly say "72 - Illustrator" and "96 - Inkscape" to better help selecting.
In most cases it doesn't really matter what DPI is used because you are just going to resize it anyway. Most users probably don't consider their SVGs to have a size in meters. It only matters when you have purposely created something with specific real-world measurements for some reason. And this would save you having to guess the proper scale factor to make it exactly perfect.
Well - sorry, not trying to be argumentative - if you know you made the art 20cm x 20 cm in your vector application, and its now 18cm - or 22cm - in blender, then rescale to the size you desire after import and reset scale.
In other words, my approach doesn't require any guesswork at all. AI say's it's 20cm, so there we are. If a user doesn't know the dpi export factor and chooses 72 vs 90 vs 96, then they are just guessing and we're back to "now scale it, and reset the scale."
You could be right. But it is also possible that you can create a document with a known-size viewbox that you then populate with multiple complex shapes of various sizes and positions. What comes into Blender are those shapes, not the viewbox around them. At that point you have to measure one of the shapes in your source and then in the target and work out the scale factor to use for all of them. You can't use the bounds as shown in Blender as that is the combined bounds of the shapes, not the original viewbox size. When going from Inkscape that is 1.066667 I think. With a DPI setting (basically saying this is made in Inkscape) it would just work.