Closed jirilebl closed 3 years ago
It is the convertPathData plugin. If I disable that, things work, and the svg gets very nicely minimized (with multipass) to 472kb
I cannot reproduce with svgo 2.0.2, although it's slow. @TrySound maybe this is also fixed?
C:\Users\xmr\Desktop>svgo -i 22.svg -o 23.svg
22.svg:
Done in 142022 ms!
2594.036 KiB - 92.3% = 199.252 KiB
Thanks. Looks like all works. I will look into performance later.
I was excited to hear that it is fixed. However,, I just tried it with newly installed svgo version 2.1.0 and it still totally kills the picture, I get a mostly empty picture:
➤ svgo -i nlin-sierpinski-mbx.svg -o test.svg
nlin-sierpinski-mbx.svg: Done in 24112 ms! 2583.887 KiB - 99.5% = 13.275 KiB
Not sure what other difference for me. I'm running on linux, Ubuntu 20.10 to be precise. Installed through npm.
Hmm, this broke again in 2.1.0 it seems @TrySound
Microsoft Windows [Version 10.0.19042.844]
(c) 2020 Microsoft Corporation. All rights reserved.
C:\Users\xmr\Desktop>node -v
v14.15.5
C:\Users\xmr\Desktop>curl -sL http://www.jirka.org/nlin-sierpinski-mbx.svg>1.svg
C:\Users\xmr\Desktop>svgo 1.svg -o 2.svg
1.svg:
Done in 38192 ms!
2583.887 KiB - 99.5% = 13.275 KiB
C:\Users\xmr\Desktop>npm i -g svgo@2.0.2
C:\Users\xmr\AppData\Roaming\npm\svgo -> C:\Users\xmr\AppData\Roaming\npm\node_modules\svgo\bin\svgo
+ svgo@2.0.2
added 1 package from 1 contributor, removed 1 package and updated 1 package in 2.9s
C:\Users\xmr\Desktop>svgo 1.svg -o 2.svg
1.svg:
Done in 145807 ms!
2583.887 KiB - 92.3% = 199.252 KiB
Better reopen the issue and add this SVG to the tests
EDIT:
Output diff between 2.0.2 and 2.1.0:
Correction, 2.0.3 also works fine. So, it seems it's something in https://github.com/svg/svgo/compare/v2.0.3...v2.1.0
EDIT: @TrySound it seems that enabling the convertStyleToAttrs
plugin fixes the issue here :S
Heh, interesting
It's not easy to fix this permanently without new style engine which would be able to compute attributes and all styles.
Though yeah enabling convertStyleToAttrs
in your case would fix the issue.
Tested to try with convertStyleToAttrs, though it took me quite a while to figure out how to do that since --enable/--disable seem to be gone from cli and if I use the snippet for config to use the extendDefaultPlugins doesn't seem to work for me: I get "Error: Cannot find module 'svgo'". Finally, just stuck the full module list from the readme in there, and added 'convertStyleToAttrs' to the module list (added it at the end), and was still not getting it to work. Still got the mostly empty output.
Got it to work by sticking convertStyleToAttrs just in front of the convertPathData plugin. But I get a slightly different size so I am assuming I still have not figured out how to simply enable the plugin, and I must have disabled something else or not the right order.
➤ svgo -i nlin-sierpinski-mbx.svg -o test.svg
nlin-sierpinski-mbx.svg: Done in 197581 ms! 2583.887 KiB - 92.2% = 200.956 KiB
To extend default plugins you need to install svgo
locally. I guess we can do better. Will think about it.
Fixed the image here https://github.com/svg/svgo/commit/79dbb4bf6e7464e946d838ade0aa23c7189762f7 ad here https://github.com/svg/svgo/commit/7901588a9f18d6ef476389405a73cd7fe42ed179. Will release today or tomorrow.
Fixed in 2.2.0
Running svgo on http://www.jirka.org/nlin-sierpinski-mbx.svg kills everything in the picture.