I'm trying to save a snap code image as a PNG, it looks like this which IIRC is an encoded UTF8 SVG, but it is a custom snap code so it could be encoded or encrypted with anything.
data:image/svg+xml;utf8,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%20standalone...
What I have so far
var imageSource = image.GetAttribute("src");
string svg = WebUtility.UrlDecode(imageSource).Replace("data:image/svg xml;utf8,", "");
byte[] svgBytes = Encoding.UTF8.GetBytes(svg);
File.WriteAllBytes(filePath, svgBytes);
Image saves but is some kind of SVG dump
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:xlink="http://www.w3.org/1999/xlink" height="320" version="1.1" viewBox="0 0 320 320" width="320" xmlns="http://www.w3.org/2000/svg">
<defs>
<rect height="320" id="rect" rx="51.2" width="320" x="0" y="0"/>
<clipPath id="clip">
<use xlink:href="#rect"/>
</clipPath>
</defs>
<use fill="#FFFC00" stroke="black" stroke-width="2" xlink:href="#rect"/>
<image clip-path="url(#clip)"