svg-net / SVG

Fork of the ms svg library
http://svg-net.github.io/SVG/
Microsoft Public License
1.17k stars 474 forks source link

Prebuilt minimal SVG to PNG converter #614

Closed RazrFalcon closed 4 years ago

RazrFalcon commented 4 years ago

Hi! I'm trying to use this library as a simple SVG-to-PNG converter, but I'm not familiar with C#, so I would not be able to build it myself. Is there are some prebuilt binaries or a build instruction for a complete beginner?

wieslawsoltes commented 4 years ago

@RazrFalcon I have created sample console application with build instructions:

https://github.com/wieslawsoltes/SVG/tree/SampleConsoleApplication/Samples/SvgConsole

RazrFalcon commented 4 years ago

Thanks. I will try it out soon.

What rendering library does it use on Linux? On Windows it uses DirectDraw, afaik, but it wasn't ported to linux yet.

wieslawsoltes commented 4 years ago

I think it uses libgdiplus

sudo apt install libc6-dev 
sudo apt install libgdiplus
wieslawsoltes commented 4 years ago

@RazrFalcon https://www.mono-project.com/docs/gui/libgdiplus/

RazrFalcon commented 4 years ago

I see. Interesting. I'm just concerned about feature set. Especially text rendering. It might be quite different from Windows implementation. Since it probably uses Uniscribe on Windows and harfbuzz on Linux.

wieslawsoltes commented 4 years ago

I am not familiar with libgdiplus internals, on windows Svg is using GDI+.

There is also Skia version of Svg called Svg.Skia https://github.com/wieslawsoltes/Svg.Skia#tool, I am the author. Text rendering is very basic at the moment.

RazrFalcon commented 4 years ago

Thanks. I'm just looking for the best implementation to compare it with resvg.

wieslawsoltes commented 4 years ago

Thanks. I'm just looking for the best implementation to compare it with resvg.

I am aware of resvg, I am using https://github.com/RazrFalcon/resvg-test-suite for testing Svg.Skia library.

There are many differences between Svg library and Svg.Skia library in terms of rendering output. Svg.Skia is using only objects model from Svg.

It would be very interesting to see the comparison between Svg, Svg.Skia and resvg.

RazrFalcon commented 4 years ago

Well, it was surprisingly easy to build. Would you mind adding a --width option, so I can set width/size of the resulting image?

UPD: looks like svgDocument.Width = 500; svgDocument.Height = 500; was enough.

Would you mind publishing it somewhere? Or should I copy-paste in to the resvg-test-suite?

wieslawsoltes commented 4 years ago

Well, it was surprisingly easy to build. Would you mind adding a --width option, so I can set width/size of the resulting image?

UPD: looks like svgDocument.Width = 500; svgDocument.Height = 500; was enough.

Would you mind publishing it somewhere? Or should I copy-paste in to the resvg-test-suite?

I will add width and height options.

As for publishing for now please just copy-paste.

RazrFalcon commented 4 years ago

Ok. I though that you're planning to push this code to the master.

RazrFalcon commented 4 years ago

Thanks again. I've published a new results. I hope I didn't mess up anything important, because results are pretty bad.

wieslawsoltes commented 4 years ago

Ok. I though that you're planning to push this code to the master.

I must have misunderstood you. I will submit PR PR with width and height options to master.

wieslawsoltes commented 4 years ago

Thanks again. I've published a new results. I hope I didn't mess up anything important, because results are pretty bad.

The results seem to be right.

In feature maybe you can add Svg.Skia to test suite too https://github.com/wieslawsoltes/Svg.Skia#tool

RazrFalcon commented 4 years ago

How much Svg.Skia differs from the SVG.NET? Is it simply a different rendering backend or is there are other changes? Because SVG.NET has a lot of SVG parsing related bugs.

wieslawsoltes commented 4 years ago

How much Svg.Skia differs from the SVG.NET? Is it simply a different rendering backend or is there are other changes? Because SVG.NET has a lot of SVG parsing related bugs.

It's different rendering engine and has some other changes too. The text part is bit behind, other parts should be better I think. The big part is filter effects, which should be better and are worked on actively to be even better in near feature.

RazrFalcon commented 4 years ago

I see. I will try it out later. It takes almost 2 hour to check all files (~1700 of them), so it's a bit time consuming.

wieslawsoltes commented 4 years ago

I see. I will try it out later. It takes almost 2 hour to check all files (~1700 of them), so it's a bit time consuming.

I understand. I think Svg.Skia can wait a bit for next round of testing in feature.

wieslawsoltes commented 4 years ago

I have added width and height properties, changed a bit command-line options (see the README.md in SvgConsole folder). Also submit PR https://github.com/vvvv/SVG/pull/676