I've been trying to convert SVG images to PNG using C#, without having to write too much code. Can anyone recommend a library or example code for doing this?
Navigate to an . svg file, right click on it and click on the context menu item 'Save SVG as PNG. Lets you click on the extension icon or right click on an . svg file and choose Save SVG as PNG.
Go to File. Select Export. Click Export As. Select JPG format from the drop-down menu.
How to convert a SVG to a PNG file? Choose the SVG file that you want to convert. Select PNG as the the format you want to convert your SVG file to. Click "Convert" to convert your SVG file.
There is a much easier way using the library http://svg.codeplex.com/ (Newer version @GIT, @NuGet). Here is my code
var byteArray = Encoding.ASCII.GetBytes(svgFileContents); using (var stream = new MemoryStream(byteArray)) { var svgDocument = SvgDocument.Open(stream); var bitmap = svgDocument.Draw(); bitmap.Save(path, ImageFormat.Png); }
You can call the command-line version of inkscape to do this:
http://harriyott.com/2008/05/converting-svg-images-to-png-in-c.aspx
Also there is a C# SVG rendering engine, primarily designed to allow SVG files to be used on the web on codeplex that might suit your needs if that is your problem:
Original Project
http://www.codeplex.com/svg
Fork with fixes and more activity: (added 7/2013)
https://github.com/vvvv/SVG
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With