title: PNG to SVG Python
body: <p>I'm trying to convert PNG images to SVG with Python but when I run this code output image can't even load in Photoshop or Browser. What am I doing wrong?</p>
  
  <pre><code>    import os
      import base64
      startSvgTag = """&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
      &lt;!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
      "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"&gt;
      &lt;svg version="1.1"
      xmlns="http://www.w3.org/2000/svg"
      xmlns:xlink="http://www.w3.org/1999/xlink"
      width="240px" height="240px" viewBox="0 0 240 240"&gt;"""
  
      endSvgTag = """&lt;/svg&gt;"""
      for files in os.listdir("."):
          if files.endswith(".png"):
              pngFile = open(files, 'rb')
              base64data = base64.b64encode(pngFile.read()).replace(b'\n',b'')
              base64String = '&lt;image xlink:href="data:image/png;base64,{0}" width="240" height="240" x="0" y="0" /&gt;'.format(base64data)
              f = open(os.path.splitext(files)[0]+".svg",'w')
              f.write( startSvgTag + base64String + endSvgTag)
              print('Converted ',files,' to ',os.path.splitext(files)[0],".svg")
  </code></pre>