title: Why am I getting ValueError when trying to render PNG?
body: <p>I have some SVGs that I would like to save as PNGs with Python. I am using svglib to handle this process. Whenever I try to <code>renderPM.drawToFile(logo, path, fmt)</code> it returns the following error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
    File &quot;C:\Users\Myself\Desktop\programming\project-folders\svg-to-png\venv\lib\site-packages\reportlab\graphics\renderPM.py&quot;, line 683, in drawToFile
      c.saveToFile(fn,fmt)
    File &quot;C:\Users\Myself\Desktop\programming\project-folders\svg-to-png\venv\lib\site-packages\reportlab\graphics\renderPM.py&quot;, line 321, in saveToFile
      im = self.toPIL()
    File &quot;C:\Users\Myself\Desktop\programming\project-folders\svg-to-png\venv\lib\site-packages\reportlab\graphics\renderPM.py&quot;, line 317, in toPIL
      (getattr(im,'frombytes',None) or getattr(im,'fromstring'))(self._gs.pixBuf)
    File &quot;C:\Users\Myself\Desktop\programming\project-folders\svg-to-png\venv\lib\site-packages\PIL\Image.py&quot;, line 827, in frombytes
      d.setimage(self.im)
  ValueError: tile cannot extend outside image
  </code></pre>
  <p>Here is the code I entered in the python shell to get these results <a href="https://pypi.org/project/svglib/" rel="nofollow noreferrer">(see documentation)</a>:</p>
  <pre><code>&gt;&gt;&gt; from svglib.svglib import svg2rlg
  &gt;&gt;&gt; from reportlab.graphics import renderPM
  &gt;&gt;&gt; logo = svg2rlg(r'C:\Users\Myself\Desktop\testenv\test.svg')
  &gt;&gt;&gt; renderPM.drawToFile(logo, r'C:\Users\Myself\Desktop\testenv\test.png', fmt='PNG') 
  </code></pre>
  <p>Here is the SVG that I am trying to export as PNG (using a very simple SVG for testing):</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;body&gt;
      &lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; height=&quot;500&quot; width=&quot;500&quot;&gt;
        &lt;polygon points=&quot;200,10 250,190 160,210&quot; style=&quot;fill:lime;stroke:purple;stroke-width:1&quot; /&gt;
      &lt;/svg&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>I have looked at many similar problems to try to find an answer, but I am not having any luck.</p>