Bug 473873 - SVG scaling issue, transforming when it shouldn't and The grid snapping doesn't work
Summary: SVG scaling issue, transforming when it shouldn't and The grid snapping doesn...
Status: CONFIRMED
Alias: None
Product: krita
Classification: Applications
Component: Layers/Vector (show other bugs)
Version: 5.1.5
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-08-28 23:33 UTC by George Hayes
Modified: 2023-09-02 02:06 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
That's the file I used to create it. (28.81 KB, application/x-krita)
2023-08-28 23:33 UTC, George Hayes
Details
attachment-4073196-0.html (1.65 KB, text/html)
2023-09-02 02:06 UTC, George Hayes
Details

Note You need to log in before you can comment on or make changes to this bug.
Description George Hayes 2023-08-28 23:33:14 UTC
Created attachment 161250 [details]
That's the file I used to create it.

It is scaling SVGs when it should not be doing so. Your grid snapping isn't snapping to the grid for it but to pixels.

STEPS TO REPRODUCE
1. I created a 128 by 128 image and then created an SVG layer on it.
2. I then created the SVG vector.

OBSERVED RESULT
After exporting it I noticed when opening it in a browser it was about 1/4 the size it should be.
So I looked at the text in the SVG and noticed it reduced it to 30.72 for both axis rather than 128.
Scaling the graphic up is entirely worthless in that the proportions of line thickness and so on then are off.

I've searched the internet and forums to see how I can tell it to not change the scale no answers any place.

SVG primary use is internet and graphics like PDF. It doesn't help to have something change what you are making into something else and you can't rely on the software to produce what it should make.

EXPECTED RESULT
I think most people would expect the size they set something to be will be the size and scale it is produced at not 1/4.1666 the size.

I'm also not a fan of the transformation being done as well. Unless I tell it to transform I don't want it doing so.
The entire reason I am building this object in SVG is so I can create characters and attach a skeleton system to them and then animate them and make it so I can automatically fit clothing from one character to another. All the transformation does is force me to recalculate everything by hand. At most I would want is transformation from  the center of the 128 by 128 area in this case. But that isn't what is being done.

So in effect the SVG produced is entirely worthless and I am hand coding the SVGs or going to use software that doesn't scale or translate unless I tell it or maybe allows me to select the translation point.

SOFTWARE/OS VERSIONS
Windows: Windows 10

ADDITIONAL INFORMATION
To be clear this is a fresh install of the software on a freshly installed Windows 10.
No changes made to it. So I haven't changed any settings this is the default behavior of the software.
Comment 1 Alvin Wong 2023-08-29 08:24:21 UTC
Yes, there are some confusing aspects of how vector layers are being handled in Krita. In particular, the current implementation of vector layers always use "pt" (1/72 inch) as the unit and that is why it is used in the exported SVG. It also takes into account the document resolution, and since your document is set to 300 ppi, 1 pt = 4.166... px (document) and therefore 128 px (document) = 30.72 pt. This makes sense to match the "print size" of the document. For web usage, since the CSS defines px to be exactly 1/96 inch, the document should be set to 96 ppi to match that.

But also unintuitively, even if you resize the image changing only the resolution to 96 ppi, exporting the layer immediately still gives you the same dimensions. This is because at this point the scale is only applied to the layer and not the shapes inside (an oddity of the implementation of "scale image"). To fix that, you have to clone the layer and export the cloned layer, or save then reopen the file.

Tl;dr: Don't use Krita as a general purpose vector editor; it's not. Use Inkscape for that.
Comment 2 George Hayes 2023-08-29 20:01:34 UTC
I did some further testing. I imported the following svg.
<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg">
	<path id="head" fill="#fedabb" fill-rule="evenodd" stroke="#000000" stroke-width="0.5" stroke-linecap="square" stroke-linejoin="bevel" 	d="M64.0 8.0 C48 8 32 24 32 40 C32 56 32 52 32 88 z"/>
</svg>
To get the correct scaling in the image it was done at 256 to get to the right size with the default 300pixels per inch and 0.43 print under scale image. But the positioning is off.
If I change it to 128resolution and 1in 128 with and 128 height. It scales perfectly at and positions perfectly.
However, if I then export that very same layer. It changes it to what is below which again is shrunk in size and transformed.
The new svg it creates can't even be properly imported back in sized and positioned without work.
My suggest is drop the transformation let the people printing it worry about that just focus on getting the point position and so on right.
Don't worry about the DPI that is an issue for the people print software.
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<!-- Created using Krita: https://krita.org -->
<svg xmlns="http://www.w3.org/2000/svg" 
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:krita="http://krita.org/namespaces/svg/krita"
    xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
    width="72pt"
    height="72pt"
    viewBox="0 0 72 72">
<defs/>
<path id="head" transform="matrix(0.5625 0 0 0.5625 18 4.5)" fill="#fedabb" fill-rule="evenodd" stroke="#000000" stroke-width="0.5" stroke-linecap="square" stroke-linejoin="bevel" d="M32 0C16 0 0 16 0 32C0 48 0 44 0 80Z" sodipodi:nodetypes="cccc"/>
</svg>
Comment 3 Alvin Wong 2023-08-30 14:12:21 UTC
Again, Krita is not a general purpose vector editor. Its vector capabilities is to allow adding vector shapes to a drawing or painting primarily for raster output. It does not aim to preserve the original SVG markup exactly as-is. It can and will change the representation of paths and shapes and apply various transform as long as the visual output looks the same. This is not going to change any time soon.

If the raw values of paths is important to you, I strongly recommend you use Inkscape instead of trying to get what you look for using Krita.

I only marked this issue as "confirmed" for the unintuitive handling of the document DPI on exporting as SVG.
Comment 4 George Hayes 2023-09-02 02:06:08 UTC
Created attachment 161334 [details]
attachment-4073196-0.html

The problem is it doesn't look the same. Why do all the extra transforms
when they are just added work for no reason.
You simply created more work for system while getting no benefit at all
from it if anything it made it worse.

On Wed, Aug 30, 2023 at 9:12 AM Alvin Wong <bugzilla_noreply@kde.org> wrote:

> https://bugs.kde.org/show_bug.cgi?id=473873
>
> --- Comment #3 from Alvin Wong <alvin@alvinhc.com> ---
> Again, Krita is not a general purpose vector editor. Its vector
> capabilities is
> to allow adding vector shapes to a drawing or painting primarily for raster
> output. It does not aim to preserve the original SVG markup exactly as-is.
> It
> can and will change the representation of paths and shapes and apply
> various
> transform as long as the visual output looks the same. This is not going to
> change any time soon.
>
> If the raw values of paths is important to you, I strongly recommend you
> use
> Inkscape instead of trying to get what you look for using Krita.
>
> I only marked this issue as "confirmed" for the unintuitive handling of the
> document DPI on exporting as SVG.
>
> --
> You are receiving this mail because:
> You reported the bug.