Writing raw SVG data to a file in python3?
<p>I have this code thus far:</p>

<pre><code>def make_png_download():
svg_data = Graphs.svgdata
with open('chart.svg', 'wb+') as file:
    file.write(svg_data)
    with wand.image.Image(blob=file.read(), format="svg") as image:
        png_image = image.make_blob("png")
    response = send_file(png_image, as_attachment=True, attachment_filename='chart.png')
    response.headers['Content-Description'] = 'Png Download'
    response.headers['Cache-Control'] = 'no-cache'
    response.headers['Content-Type'] = 'image/png'
    response.headers['Content-Disposition'] = 'attachment; filename=chart.png'
    return response
</code></pre>

<p>I am attempting to write to a file so that I can convert it with wand imported module (from svg to png) but getting an error 'wand.exceptions.BlobError: zero-length blob not permitted `buffer.svg' @ error/blob.c/BlobToImage/343'</p>

<p>I think this is happening because after trying to write to the file it is blank - Can anyone advise what I'm doing wrong here so I can write to the file correctly?</p>

<p>If I print svg_data it returns: 
<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>b'&lt;?xml version=\'1.0\' encoding=\'utf-8\'?&gt;\n&lt;svg xmlns:xlink="http://www.w3.org/1999/xlink" class="pygal-chart" id="chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958" viewBox="0 0 800 600" xmlns="http://www.w3.org/2000/svg"&gt;&lt;!--Generated with pygal 2.2.3 (etree) \xc2\xa9Kozea 2012-2016 on 2016-11-02--&gt;&lt;!--http://pygal.org--&gt;&lt;!--http://github.com/Kozea/pygal--&gt;&lt;defs&gt;&lt;style type="text/css"&gt;#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958{-webkit-user-select:none;-webkit-font-smoothing:antialiased;font-family:Yuppy SC,bold}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .title{font-family:Yuppy SC;font-size:25px}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .legends .legend text{font-family:Yuppy SC;font-size:14px}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis text{font-family:Yuppy SC;font-size:16px}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis text.major{font-family:Yuppy SC,bold;font-size:16px}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .text-overlay text.value{font-family:Yuppy SC,bold;font-size:22px}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .text-overlay text.label{font-family:Yuppy SC,bold;font-size:20px}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .tooltip{font-family:Yuppy SC;font-size:20px}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 text.no_data{font-family:Yuppy SC,bold;font-size:64px}\n#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958{background-color:transparent}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 path,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 line,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 rect,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 circle{-webkit-transition:400ms ease-in;-moz-transition:400ms ease-in;transition:400ms ease-in}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .graph &amp;gt; .background{fill:transparent}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .plot &amp;gt; .background{fill:white}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .graph{fill:#555555}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 text.no_data{fill:#555555}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .title{fill:#555555}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .legends .legend text{fill:#555555}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .legends .legend:hover text{fill:#555555}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis .line{stroke:#555555}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis .guide.line{stroke:#555555}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis .major.line{stroke:#555555}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis text.major{fill:#555555}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis.y .guides:hover .guide.line,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .line-graph .axis.x .guides:hover .guide.line,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .stackedline-graph .axis.x .guides:hover .guide.line,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .xy-graph .axis.x .guides:hover .guide.line{stroke:#555555}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis .guides:hover text{fill:#555555}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .reactive{fill-opacity:.7;stroke-opacity:.8}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .ci{stroke:#555555}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .reactive.active,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .active .reactive{fill-opacity:.9;stroke-opacity:.9;stroke-width:4}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .ci .reactive.active{stroke-width:1.5}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .series text{fill:#555555}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .tooltip rect{fill:white;stroke:#555555;-webkit-transition:opacity 400ms ease-in;-moz-transition:opacity 400ms ease-in;transition:opacity 400ms ease-in}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .tooltip .label{fill:#555555}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .tooltip .label{fill:#555555}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .tooltip .legend{font-size:.8em;fill:#555555}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .tooltip .x_label{font-size:.6em;fill:#555555}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .tooltip .xlink{font-size:.5em;text-decoration:underline}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .tooltip .value{font-size:1.5em}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .bound{font-size:.5em}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .max-value{font-size:.75em;fill:#555555}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .map-element{fill:white;stroke:#555555 !important}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .map-element .reactive{fill-opacity:inherit;stroke-opacity:inherit}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-0,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-0 a:visited{stroke:#7bb025;fill:#7bb025}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-1,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-1 a:visited{stroke:#f37400;fill:#f37400}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-2,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-2 a:visited{stroke:#3596bd;fill:#3596bd}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-3,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-3 a:visited{stroke:#c73b3a;fill:#c73b3a}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-4,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-4 a:visited{stroke:#ac99a0;fill:#ac99a0}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-5,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-5 a:visited{stroke:#df983e;fill:#df983e}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-6,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-6 a:visited{stroke:#ffc208;fill:#ffc208}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-7,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-7 a:visited{stroke:#d0551b;fill:#d0551b}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-8,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-8 a:visited{stroke:#db160b;fill:#db160b}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-9,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-9 a:visited{stroke:#3575db;fill:#3575db}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-10,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-10 a:visited{stroke:#1a2508;fill:#1a2508}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-11,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-11 a:visited{stroke:#4b2400;fill:#4b2400}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-12,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .color-12 a:visited{stroke:#102e3a;fill:#102e3a}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .text-overlay .color-0 text{fill:black}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .text-overlay .color-1 text{fill:black}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .text-overlay .color-2 text{fill:black}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .text-overlay .color-3 text{fill:black}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .text-overlay .color-4 text{fill:black}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .text-overlay .color-5 text{fill:black}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .text-overlay .color-6 text{fill:black}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .text-overlay .color-7 text{fill:black}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .text-overlay .color-8 text{fill:black}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .text-overlay .color-9 text{fill:black}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .text-overlay .color-10 text{fill:white}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .text-overlay .color-11 text{fill:white}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .text-overlay .color-12 text{fill:white}\n#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 text.no_data{text-anchor:middle}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .guide.line{fill:none}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .centered{text-anchor:middle}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .title{text-anchor:middle}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .legends .legend text{fill-opacity:1}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis.x text{text-anchor:middle}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis.x:not(.web) text[transform]{text-anchor:start}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis.x:not(.web) text[transform].backwards{text-anchor:end}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis.y text{text-anchor:end}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis.y text[transform].backwards{text-anchor:start}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis.y2 text{text-anchor:start}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis.y2 text[transform].backwards{text-anchor:end}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis .guide.line{stroke-dasharray:4,4}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis .major.guide.line{stroke-dasharray:6,6}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .horizontal .axis.y .guide.line,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .horizontal .axis.y2 .guide.line,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .vertical .axis.x .guide.line{opacity:0}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .horizontal .axis.always_show .guide.line,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .vertical .axis.always_show .guide.line{opacity:1 !important}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis.y .guides:hover .guide.line,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis.y2 .guides:hover .guide.line,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis.x .guides:hover .guide.line{opacity:1}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .axis .guides:hover text{opacity:1}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .nofill{fill:none}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .subtle-fill{fill-opacity:.2}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .dot{stroke-width:1px;fill-opacity:1}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .dot.active{stroke-width:5px}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .dot.negative{fill:transparent}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 text,#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 tspan{stroke:none !important}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .series text.active{opacity:1}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .tooltip rect{fill-opacity:.95;stroke-width:.5}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .tooltip text{fill-opacity:1}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .showable{visibility:hidden}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .showable.shown{visibility:visible}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .gauge-background{fill:rgba(229,229,229,1);stroke:none}#chart-1d0a0c14-5022-4e9e-b1a7-698ffda55958 .bg-lines{stroke:transparent;stroke-width:2px}&lt;/style&gt;&lt;script type="text/javascript"&gt;window.pygal = window.pygal || {};window.pygal.config = window.pygal.config || {};window.pygal.config[\'1d0a0c14-5022-4e9e-b1a7-698ffda55958\'] = {"inner_radius": 0.3, "dynamic_print_values": false, "interpolation_precision": 250, "tooltip_border_radius": 0, "legend_at_bottom": false, "margin_top": null, "print_zeroes": true, "stroke": true, "x_labels": null, "height": 600, "logarithmic": false, "pretty_print": false, "tooltip_fancy_mode": true, "margin_right": null, "xrange": null, "allow_interruptions": false, "interpolation_parameters": {}, "show_x_guides": false, "x_title": null, "style": {"label_font_size": 16, "title_font_family": "Yuppy SC", "background": "transparent", "no_data_font_family": "Yuppy SC, bold", "value_background": "rgba(229, 229, 229, 1)", "stroke_opacity_hover": ".9", "ci_colors": [], "tooltip_font_size": 20, "stroke_opacity": ".8", "guide_stroke_dasharray": "4,4", "legend_font_family": "Yuppy SC", "foreground": "#555555", "transition": "400ms ease-in", "major_guide_stroke_dasharray": "6,6", "opacity_hover": ".9", "foreground_strong": "#555555", "value_label_font_size": 20, "major_label_font_size": 16, "value_colors": [], "value_font_size": 22, "opacity": ".7", "value_font_family": "Yuppy SC, bold", "tooltip_font_family": "Yuppy SC", "major_label_font_family": "Yuppy SC, bold", "value_label_font_family": "Yuppy SC, bold", "font_family": "Yuppy SC, bold", "legend_font_size": 14, "title_font_size": 25, "label_font_family": "Yuppy SC", "foreground_subtle": "#555555", "colors": ["#7BB025", "#F37400", "#3596BD", "#C73B3A", "#AC99A0", "#DF983E", "#FFC208", "#D0551B", "#DB160B", "#3575DB"], "no_data_font_size": 64, "plot_background": "white"}, "force_uri_protocol": "https", "disable_xml_declaration": false, "css": ["file://style.css", "file://graph.css"], "print_values": false, "x_labels_major_count": null, "explicit_size": false, "y_labels": null, "fill": false, "legends": ["Frames", "Cards", "Gifts", "Frontiers", "Supply Chain &amp;amp; Logistics", "WH", "Poli", "Wall Decor", "Canvas", "Prints", "Logistics", "Mugs", "3D Sublimation"], "width": 800, "no_prefix": false, "stroke_style": null, "margin": 20, "x_labels_major": null, "defs": [], "y_title": null, "margin_bottom": null, "print_values_position": "center", "show_y_labels": true, "range": null, "interpolate": null, "max_scale": 16, "y_labels_major_count": null, "order_min": null, "dots_size": 2.5, "y_label_rotation": 0, "y_labels_major": null, "title": "Precentage of Absence per Team (%)", "x_label_rotation": 0, "classes": ["pygal-chart"], "truncate_legend": null, "missing_value_fill_truncation": "x", "show_x_labels": true, "show_minor_x_labels": true, "strict": false, "show_dots": true, "x_labels_major_every": null, "secondary_range": null, "box_mode": "extremes", "rounded_bars": null, "show_y_guides": true, "zero": 0, "no_data_text": "No data", "half_pie": false, "inverse_y_axis": false, "margin_left": null, "formatter": null, "stack_from_top": false, "min_scale": 4, "spacing": 10, "y_labels_major_every": null, "legend_box_size": 22, "show_only_major_dots": false, "print_labels": false, "include_x_axis": false, "js": ["//kozea.github.io/pygal.js/2.0.x/pygal-tooltips.min.js"], "truncate_label": null, "legend_at_bottom_columns": null, "show_minor_y_labels": true, "show_legend": true}&lt;/script&gt;&lt;script type="text/javascript" xlink:href="https://kozea.github.io/pygal.js/2.0.x/pygal-tooltips.min.js" /&gt;&lt;/defs&gt;&lt;title&gt;Precentage of Absence per Team (%)&lt;/title&gt;&lt;g class="graph pie-graph vertical"&gt;&lt;rect class="background" height="600" width="800" x="0" y="0" /&gt;&lt;g class="plot" transform="translate(178, 55)"&gt;&lt;rect class="background" height="525" width="602.0" x="0" y="0" /&gt;&lt;g class="series serie-0 color-0"&gt;&lt;g class="slices"&gt;&lt;g class="slice"&gt;&lt;a xlink:href="http://127.0.0.1:4996/download-chart"&gt;&lt;desc class="xlink"&gt;http://127.0.0.1:4996/download-chart&lt;/desc&gt;&lt;path class="slice reactive tooltip-trigger" d="M301.000000 26.250000 A236.250000 236.250000 0 0 1 359.280948 33.551548 L320.426983 186.183849 A78.750000 78.750000 0 0 0 301.000000 183.750000 z" /&gt;&lt;desc class="value"&gt;1.13%&lt;/desc&gt;&lt;desc class="x centered"&gt;320.5788477886972&lt;/desc&gt;&lt;desc class="y centered"&gt;106.22166266795955&lt;/desc&gt;&lt;/a&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="series serie-1 color-1"&gt;&lt;g class="slices"&gt;&lt;g class="slice"&gt;&lt;a xlink:href="http://127.0.0.1:4996/download-chart"&gt;&lt;desc class="xlink"&gt;http://127.0.0.1:4996/download-chart&lt;/desc&gt;&lt;path class="slice reactive tooltip-trigger" d="M359.280948 33.551548 A236.250000 236.250000 0 0 1 446.565071 76.422402 L349.521690 200.474134 A78.750000 78.750000 0 0 0 320.426983 186.183849 z" /&gt;&lt;desc class="value"&gt;1.88%&lt;/desc&gt;&lt;desc class="x centered"&gt;370.43510932052936&lt;/desc&gt;&lt;desc class="y centered"&gt;121.13163156615926&lt;/desc&gt;&lt;/a&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="series serie-2 color-2"&gt;&lt;g class="slices"&gt;&lt;g class="slice"&gt;&lt;a xlink:href="http://127.0.0.1:4996/download-chart"&gt;&lt;desc class="xlink"&gt;http://127.0.0.1:4996/download-chart&lt;/desc&gt;&lt;path class="slice reactive tooltip-trigger" d="M446.565071 76.422402 A236.250000 236.250000 0 0 1 482.918572 111.769461 L361.639524 212.256487 A78.750000 78.750000 0 0 0 349.521690 200.474134 z" /&gt;&lt;desc class="value"&gt;0.975%&lt;/desc&gt;&lt;desc class="x centered"&gt;410.7952393652246&lt;/desc&gt;&lt;desc class="y centered"&gt;149.57854316945327&lt;/desc&gt;&lt;/a&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="series serie-3 color-3"&gt;&lt;g class="slices"&gt;&lt;g class="slice"&gt;&lt;a xlink:href="http://127.0.0.1:4996/download-chart"&gt;&lt;desc class="xlink"&gt;http://127.0.0.1:4996/download-chart&lt;/desc&gt;&lt;path class="slice reactive tooltip-trigger" d="M482.918572 111.769461 A236.250000 236.250000 0 0 1 513.533884 159.333092 L371.844628 228.111031 A78.750000 78.750000 0 0 0 361.639524 212.256487 z" /&gt;&lt;desc class="value"&gt;1.09%&lt;/desc&gt;&lt;desc class="x centered"&gt;433.4365839963262&lt;/desc&gt;&lt;desc class="y centered"&gt;177.25446510588347&lt;/desc&gt;&lt;/a&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="series serie-4 color-4"&gt;&lt;g class="slices"&gt;&lt;g class="slice"&gt;&lt;a xlink:href="http://127.0.0.1:4996/download-chart"&gt;&lt;desc class="xlink"&gt;http://127.0.0.1:4996/download-chart&lt;/desc&gt;&lt;path class="slice reactive tooltip-trigger" d="M513.533884 159.333092 A236.250000 236.250000 0 0 1 533.929875 223.031840 L378.643292 249.343947 A78.750000 78.750000 0 0 0 371.844628 228.111031 z" /&gt;&lt;desc class="value"&gt;1.29%&lt;/desc&gt;&lt;desc class="x centered"&gt;450.9983300131739&lt;/desc&gt;&lt;desc class="y centered"&gt;214.4713523690395&lt;/desc&gt;&lt;/a&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="series serie-5 color-5"&gt;&lt;g class="slices"&gt;&lt;g class="slice"&gt;&lt;a xlink:href="http://127.0.0.1:4996/download-chart"&gt;&lt;desc class="xlink"&gt;http://127.0.0.1:4996/download-chart&lt;/desc&gt;&lt;path class="slice reactive tooltip-trigger" d="M533.929875 223.031840 A236.250000 236.250000 0 0 1 370.946735 488.157964 L324.315578 337.719321 A78.750000 78.750000 0 0 0 378.643292 249.343947 z" /&gt;&lt;desc class="value"&gt;6.52%&lt;/desc&gt;&lt;desc class="x centered"&gt;435.17488697510225&lt;/desc&gt;&lt;desc class="y centered"&gt;344.9824205829251&lt;/desc&gt;&lt;/a&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="series serie-6 color-6"&gt;&lt;g class="slices"&gt;&lt;g class="slice"&gt;&lt;a xlink:href="http://127.0.0.1:4996/download-chart"&gt;&lt;desc class="xlink"&gt;http://127.0.0.1:4996/download-chart&lt;/desc&gt;&lt;path class="slice reactive tooltip-trigger" d="M370.946735 488.157964 A236.250000 236.250000 0 0 1 291.481953 498.558190 L297.827318 341.186063 A78.750000 78.750000 0 0 0 324.315578 337.719321 z" /&gt;&lt;desc class="value"&gt;1.55%&lt;/desc&gt;&lt;desc class="x centered"&gt;321.43904510959067&lt;/desc&gt;&lt;desc class="y centered"&gt;418.6681639611868&lt;/desc&gt;&lt;/a&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="series serie-7 color-7"&gt;&lt;g class="slices"&gt;&lt;g class="slice"&gt;&lt;a xlink:href="http://127.0.0.1:4996/download-chart"&gt;&lt;desc class="xlink"&gt;http://127.0.0.1:4996/download-chart&lt;/desc&gt;&lt;path class="slice reactive tooltip-trigger" d="M291.481953 498.558190 A236.250000 236.250000 0 0 1 183.863235 467.665886 L261.954412 330.888629 A78.750000 78.750000 0 0 0 297.827318 341.186063 z" /&gt;&lt;desc class="value"&gt;2.17%&lt;/desc&gt;&lt;desc class="x centered"&gt;257.5440506857186&lt;/desc&gt;&lt;desc class="y centered"&gt;413.8863615693125&lt;/desc&gt;&lt;/a&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="series serie-8 color-8"&gt;&lt;g class="slices"&gt;&lt;g class="slice"&gt;&lt;a xlink:href="http://127.0.0.1:4996/download-chart"&gt;&lt;desc class="xlink"&gt;http://127.0.0.1:4996/download-chart&lt;/desc&gt;&lt;path class="slice reactive tooltip-trigger" d="M183.863235 467.665886 A236.250000 236.250000 0 0 1 97.052895 381.746135 L233.017632 302.248712 A78.750000 78.750000 0 0 0 261.954412 330.888629 z" /&gt;&lt;desc class="value"&gt;2.37%&lt;/desc&gt;&lt;desc class="x centered"&gt;190.20637043159743&lt;/desc&gt;&lt;desc class="y centered"&gt;374.44204593029195&lt;/desc&gt;&lt;/a&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="series serie-9 color-9"&gt;&lt;g class="slices"&gt;&lt;g class="slice"&gt;&lt;a xlink:href="http://127.0.0.1:4996/download-chart"&gt;&lt;desc class="xlink"&gt;http://127.0.0.1:4996/download-chart&lt;/desc&gt;&lt;path class="slice reactive tooltip-trigger" d="M97.052895 381.746135 A236.250000 236.250000 0 0 1 65.452254 280.702248 L222.484085 268.567416 A78.750000 78.750000 0 0 0 233.017632 302.248712 z" /&gt;&lt;desc class="value"&gt;2.05%&lt;/desc&gt;&lt;desc class="x centered"&gt;150.67975242492986&lt;/desc&gt;&lt;desc class="y centered"&gt;309.5114153048982&lt;/desc&gt;&lt;/a&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="series serie-10 color-10"&gt;&lt;g class="slices"&gt;&lt;g class="slice"&gt;&lt;a xlink:href="http://127.0.0.1:4996/download-chart"&gt;&lt;desc class="xlink"&gt;http://127.0.0.1:4996/download-chart&lt;/desc&gt;&lt;path class="slice reactive tooltip-trigger" d="M65.452254 280.702248 A236.250000 236.250000 0 0 1 70.070074 212.645894 L224.023358 245.881965 A78.750000 78.750000 0 0 0 222.484085 268.567416 z" /&gt;&lt;desc class="value"&gt;1.31%&lt;/desc&gt;&lt;desc class="x centered"&gt;143.86131899861402&lt;/desc&gt;&lt;desc class="y centered"&gt;251.83768631371902&lt;/desc&gt;&lt;/a&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="series serie-11 color-11"&gt;&lt;g class="slices"&gt;&lt;g class="slice"&gt;&lt;a xlink:href="http://127.0.0.1:4996/download-chart"&gt;&lt;desc class="xlink"&gt;http://127.0.0.1:4996/download-chart&lt;/desc&gt;&lt;path class="slice reactive tooltip-trigger" d="M70.070074 212.645894 A236.250000 236.250000 0 0 1 267.142625 28.688664 L289.714208 184.562888 A78.750000 78.750000 0 0 0 224.023358 245.881965 z" /&gt;&lt;desc class="value"&gt;5.51%&lt;/desc&gt;&lt;desc class="x centered"&gt;193.52774154611257&lt;/desc&gt;&lt;desc class="y centered"&gt;147.36545408600935&lt;/desc&gt;&lt;/a&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="series serie-12 color-12"&gt;&lt;g class="slices"&gt;&lt;g class="slice"&gt;&lt;a xlink:href="http://127.0.0.1:4996/download-chart"&gt;&lt;desc class="xlink"&gt;http://127.0.0.1:4996/download-chart&lt;/desc&gt;&lt;path class="slice reactive tooltip-trigger" d="M267.142625 28.688664 A236.250000 236.250000 0 0 1 301.000000 26.250000 L301.000000 183.750000 A78.750000 78.750000 0 0 0 289.714208 184.562888 z" /&gt;&lt;desc class="value"&gt;0.652%&lt;/desc&gt;&lt;desc class="x centered"&gt;289.68497101008614&lt;/desc&gt;&lt;desc class="y centered"&gt;105.40696985875724&lt;/desc&gt;&lt;/a&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="titles"&gt;&lt;text class="title plot_title" x="400.0" y="35"&gt;Precentage of Absence per Team (%)&lt;/text&gt;&lt;/g&gt;&lt;g class="plot overlay" transform="translate(178, 55)"&gt;&lt;g class="series serie-0 color-0" /&gt;&lt;g class="series serie-1 color-1" /&gt;&lt;g class="series serie-2 color-2" /&gt;&lt;g class="series serie-3 color-3" /&gt;&lt;g class="series serie-4 color-4" /&gt;&lt;g class="series serie-5 color-5" /&gt;&lt;g class="series serie-6 color-6" /&gt;&lt;g class="series serie-7 color-7" /&gt;&lt;g class="series serie-8 color-8" /&gt;&lt;g class="series serie-9 color-9" /&gt;&lt;g class="series serie-10 color-10" /&gt;&lt;g class="series serie-11 color-11" /&gt;&lt;g class="series serie-12 color-12" /&gt;&lt;/g&gt;&lt;g class="plot text-overlay" transform="translate(178, 55)"&gt;&lt;g class="series serie-0 color-0" /&gt;&lt;g class="series serie-1 color-1" /&gt;&lt;g class="series serie-2 color-2" /&gt;&lt;g class="series serie-3 color-3" /&gt;&lt;g class="series serie-4 color-4" /&gt;&lt;g class="series serie-5 color-5" /&gt;&lt;g class="series serie-6 color-6" /&gt;&lt;g class="series serie-7 color-7" /&gt;&lt;g class="series serie-8 color-8" /&gt;&lt;g class="series serie-9 color-9" /&gt;&lt;g class="series serie-10 color-10" /&gt;&lt;g class="series serie-11 color-11" /&gt;&lt;g class="series serie-12 color-12" /&gt;&lt;/g&gt;&lt;g class="plot tooltip-overlay" transform="translate(178, 55)"&gt;&lt;g class="tooltip" style="opacity: 0" transform="translate(0 0)"&gt;&lt;rect class="tooltip-box" height="0" rx="0" ry="0" width="0" /&gt;&lt;g class="text" /&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="legends" transform="translate(10, 65)"&gt;&lt;g class="legend reactive activate-serie" id="activate-serie-0"&gt;&lt;rect class="color-0 reactive" height="22" width="22" x="0.0" y="0.0" /&gt;&lt;text x="27.0" y="15.2"&gt;Frames&lt;/text&gt;&lt;/g&gt;&lt;g class="legend reactive activate-serie" id="activate-serie-1"&gt;&lt;rect class="color-1 reactive" height="22" width="22" x="0.0" y="33.0" /&gt;&lt;text x="27.0" y="48.2"&gt;Cards&lt;/text&gt;&lt;/g&gt;&lt;g class="legend reactive activate-serie" id="activate-serie-2"&gt;&lt;rect class="color-2 reactive" height="22" width="22" x="0.0" y="66.0" /&gt;&lt;text x="27.0" y="81.2"&gt;Gifts&lt;/text&gt;&lt;/g&gt;&lt;g class="legend reactive activate-serie" id="activate-serie-3"&gt;&lt;rect class="color-3 reactive" height="22" width="22" x="0.0" y="99.0" /&gt;&lt;text x="27.0" y="114.2"&gt;Frontiers&lt;/text&gt;&lt;/g&gt;&lt;g class="legend reactive activate-serie" id="activate-serie-4"&gt;&lt;rect class="color-4 reactive" height="22" width="22" x="0.0" y="132.0" /&gt;&lt;text x="27.0" y="147.2"&gt;Supply Chain &amp;amp;\xe2\x80\xa6&lt;/text&gt;&lt;title&gt;Supply Chain &amp;amp; Logistics&lt;/title&gt;&lt;/g&gt;&lt;g class="legend reactive activate-serie" id="activate-serie-5"&gt;&lt;rect class="color-5 reactive" height="22" width="22" x="0.0" y="165.0" /&gt;&lt;text x="27.0" y="180.2"&gt;WH&lt;/text&gt;&lt;/g&gt;&lt;g class="legend reactive activate-serie" id="activate-serie-6"&gt;&lt;rect class="color-6 reactive" height="22" width="22" x="0.0" y="198.0" /&gt;&lt;text x="27.0" y="213.2"&gt;Poli&lt;/text&gt;&lt;/g&gt;&lt;g class="legend reactive activate-serie" id="activate-serie-7"&gt;&lt;rect class="color-7 reactive" height="22" width="22" x="0.0" y="231.0" /&gt;&lt;text x="27.0" y="246.2"&gt;Wall Decor&lt;/text&gt;&lt;/g&gt;&lt;g class="legend reactive activate-serie" id="activate-serie-8"&gt;&lt;rect class="color-8 reactive" height="22" width="22" x="0.0" y="264.0" /&gt;&lt;text x="27.0" y="279.2"&gt;Canvas&lt;/text&gt;&lt;/g&gt;&lt;g class="legend reactive activate-serie" id="activate-serie-9"&gt;&lt;rect class="color-9 reactive" height="22" width="22" x="0.0" y="297.0" /&gt;&lt;text x="27.0" y="312.2"&gt;Prints&lt;/text&gt;&lt;/g&gt;&lt;g class="legend reactive activate-serie" id="activate-serie-10"&gt;&lt;rect class="color-0 reactive" height="22" width="22" x="0.0" y="330.0" /&gt;&lt;text x="27.0" y="345.2"&gt;Logistics&lt;/text&gt;&lt;/g&gt;&lt;g class="legend reactive activate-serie" id="activate-serie-11"&gt;&lt;rect class="color-1 reactive" height="22" width="22" x="0.0" y="363.0" /&gt;&lt;text x="27.0" y="378.2"&gt;Mugs&lt;/text&gt;&lt;/g&gt;&lt;g class="legend reactive activate-serie" id="activate-serie-12"&gt;&lt;rect class="color-2 reactive" height="22" width="22" x="0.0" y="396.0" /&gt;&lt;text x="27.0" y="411.2"&gt;3D Sublimation&lt;/text&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="legends" transform="translate(790, 65)" /&gt;&lt;/g&gt;&lt;/svg&gt;'</code></pre>
</div>
</div>
</p>

<p>The wand.image.Image(blob=) expects a bytearray/bytes type object which I think is required for the raw svg content, hence I am opening with the 'wb+' permission in the with open() context manager but maybe this is wrong in some way?<br>
I have also tried encoding the data to utf-8 when writing to the file with file.write(svg_data.encode('utf-8') but this didn't seem to work either.</p>

<p>EDIT:</p>

<pre><code>def make_png_download():
svg_data = Graphs.svgdata
with open('chart.svg', 'wb+') as file:
    file.write(svg_data)
with open(file, 'rb') as rfile:
    with wand.image.Image(blob=rfile.read(), format="svg") as image:
        png_image = image.make_blob("png")
    response = send_file(png_image, as_attachment=True, attachment_filename='chart.png')
</code></pre>