question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

attached svg file to png not working

See original GitHub issue

using dotnet 6

using System.Drawing.Imaging;
using System.Xml;
using Svg;

string directory = AppContext.BaseDirectory;
string inputSvgFile = Path.Combine(directory, "input.svg");
string outputPngFile = Path.Combine(directory, "output.png");
string svg = File.ReadAllText(inputSvgFile);

XmlDocument doc = new();
doc.LoadXml(svg);
var svgDoc = SvgDocument.Open(doc);
var bitmap = svgDoc.Draw();
bitmap.Save(outputPngFile, ImageFormat.Png);

input.svg.zip

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mrbean-bremencommented, Oct 19, 2022

For reference: the problem has appeared after this commit with version 3.4.0. The same is true for the image in #1013.

0reactions
kzhui125commented, Oct 23, 2022

you can use this code to generate some test svg files:

using Net.Codecrete.QrCodeGenerator;

string directory = AppContext.BaseDirectory;

string outputDir = Path.Combine(directory, "output");
Directory.CreateDirectory(outputDir);

Random rand = new Random(12345);
var queryInputData = Enumerable.Repeat(0, 20000)
    .Select(_ => BitConverter.GetBytes(rand.Next()))
    .SelectMany(x => x);

var queryItems =
    from pair in queryInputData.Chunk(1500)
        .Select((Chunk, Index) => (Chunk, Index))
    let index = pair.Index
    let chunk = pair.Chunk
    let text = Convert.ToBase64String(chunk)
    let qr = QrCode.EncodeText(text, QrCode.Ecc.Medium)
    let Svg = qr.ToSvgString(4)
    let OutputSvgFile = Path.Combine(outputDir, $"test-{index}.svg")
    select new { Svg, OutputSvgFile };

foreach (var item in queryItems)
{
    File.WriteAllText(item.OutputSvgFile, item.Svg);
}
<PackageReference Include="Net.Codecrete.QrCodeGenerator" Version="2.0.3" />
Read more comments on GitHub >

github_iconTop Results From Across the Web

imageMagick not working, to convert the SVG (SVG having ...
Given all your data downloaded to my computer, I can convert it to png using ImageMagick 6.9.10.82 Q16 Mac OSX Sierra that calls...
Read more >
Export to PNG doesn't display SVG images #347
When exporting the attached drawio file (inside the zip) as PNG, the SVG image isn't shown. It doesn't happen with the online version...
Read more >
Illustrator Export not working right with my SVG file
Hello Everyone, For some reason, my svg file is not exporting correctly when I am using illustrator. I have attached a PNG of...
Read more >
Converting large SVG to PNG file - inkscape
So I have a 16mb SVG file with about 30,000 nodes and I've been trying to convert it to a 10,000x10,000 png image....
Read more >
Image uploads: unsupported items
When uploading .svg or .dxf files into Cricut Design Space, you may receive the following error message: "Your file includes unsupported items.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found