svg import wrong shape #55601

Closed
opened 2018-06-24 08:31:58 +02:00 by Cyp · 8 comments

When importing an .svg file, the imported curve is wrong. It seems related to the 'q' parts of the path.

In the case of a nondegenerate 'q', something goes wrong at the second 'q' in the first (red) path.

In the case of a degenerate 'q', somehow the 'z' connector in the second (blue) path gets curved, even though 'z' should always be a straight line.

Also, the image should be 1m × 1m, but is imported with the wrong size due to #50048 (SVG Import scaling is wrong on some files).

Blender version is 2.79.

blenderp.svg

blenderp.png


On an unrelated note, I think 1in = 96px in css and svg, and there's a few typos in svg_import.py. svgdpi.diff

When importing an .svg file, the imported curve is wrong. It seems related to the 'q' parts of the path. In the case of a nondegenerate 'q', something goes wrong at the second 'q' in the first (red) path. In the case of a degenerate 'q', somehow the 'z' connector in the second (blue) path gets curved, even though 'z' should always be a straight line. Also, the image should be 1m × 1m, but is imported with the wrong size due to #50048 (SVG Import scaling is wrong on some files). Blender version is 2.79. ![blenderp.svg](https://archive.blender.org/developer/F3785709/blenderp.svg) ![blenderp.png](https://archive.blender.org/developer/F3785710/blenderp.png) ---- On an unrelated note, I think 1in = 96px in css and svg, and there's a few typos in svg_import.py. [svgdpi.diff](https://archive.blender.org/developer/F3785738/svgdpi.diff)
Author

Added subscriber: @cyp-2

Added subscriber: @cyp-2

Added subscribers: @Sergey, @mont29

Added subscribers: @Sergey, @mont29
Sergey Sharybin was assigned by Bastien Montagne 2018-07-23 10:10:04 +02:00

@Sergey think you kind of maintain this addon? Thanks.

@Sergey think you kind of maintain this addon? Thanks.
Author

Another issue I've run into is that if a single path (even with just straight lines) contains the same vertex twice, the imported path is wrong, as the repeated vertex is skipped. I think d="M0,0 M1,0 M1,1 M2,1 M2,2 M1,2 M1,1 M0,1 z" would reproduce the problem (haven't tested). Should that be in a separate bug report?

Another issue I've run into is that if a single path (even with just straight lines) contains the same vertex twice, the imported path is wrong, as the repeated vertex is skipped. I think d="M0,0 M1,0 M1,1 M2,1 M2,2 M1,2 M1,1 M0,1 z" would reproduce the problem (haven't tested). Should that be in a separate bug report?

Applied the fix for typos, leaving DPI part away for now. SVG by itself does not provide any specification about what is the value for DPI is expected to be (which is understandable). But at the same time Inkscape assumes it is 90. Some other formats assumes 72. So it is a bit of a mess, and needs some smart solution, if any.

The original issue is still to be looked into.

Applied the fix for typos, leaving DPI part away for now. SVG by itself does not provide any specification about what is the value for DPI is expected to be (which is understandable). But at the same time Inkscape assumes it is 90. Some other formats assumes 72. So it is a bit of a mess, and needs some smart solution, if any. The original issue is still to be looked into.
Author

According to https://www.w3.org/TR/SVG/coords.html#Units, 96px = 1in. Note that 1px is not necessarily the size of 1 physical pixel, especially on newer devices with higher pixel densities.

The three rectangles on the left demonstrate the use of one of the absolute unit identifiers, the "in" unit (inch). CSS defines 1 inch to be equal to 96 pixels. Therefore, the topmost rectangle, which is specified in inches, is exactly the same size as the middle rectangle, which is specified in user units such that there are 96 user units for each corresponding inch in the topmost rectangle. The bottom rectangle of the group illustrates what happens when values specified in inches are scaled.

According to http://wiki.inkscape.org/wiki/index.php/Units_In_Inkscape, Inkscape was fixed to use 96px = 1in version 0.91, even though it previously used to think 90px was 1in.

The page size is defined by the SVG 'width'/'height' attributes. Pre-0.91 the scale is 'user unit' == 1px with the assumption of 90dpi. To correct for 96dpi, set the 'width' and 'height' attributes using 'mm' or 'in' and add a 'viewBox' calculated at 90dpi. In 0.91, one can set the 'viewBox' to define the 'user unit' to be 1px, 1mm, 1in, etc.

According to https://www.w3.org/TR/SVG/coords.html#Units, 96px = 1in. Note that 1px is not necessarily the size of 1 physical pixel, especially on newer devices with higher pixel densities. > The three rectangles on the left demonstrate the use of one of the absolute unit identifiers, the "in" unit (inch). CSS defines 1 inch to be equal to 96 pixels. Therefore, the topmost rectangle, which is specified in inches, is exactly the same size as the middle rectangle, which is specified in user units such that there are 96 user units for each corresponding inch in the topmost rectangle. The bottom rectangle of the group illustrates what happens when values specified in inches are scaled. According to http://wiki.inkscape.org/wiki/index.php/Units_In_Inkscape, Inkscape was fixed to use 96px = 1in version 0.91, even though it previously used to think 90px was 1in. > The page size is defined by the SVG 'width'/'height' attributes. Pre-0.91 the scale is 'user unit' == 1px with the assumption of 90dpi. To correct for 96dpi, set the 'width' and 'height' attributes using 'mm' or 'in' and add a 'viewBox' calculated at 90dpi. In 0.91, one can set the 'viewBox' to define the 'user unit' to be 1px, 1mm, 1in, etc.

This issue was referenced by c2aef4a98f

This issue was referenced by c2aef4a98f6cabef9a6d38a33035f02cf8233dd0

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#55601
No description provided.