Python - tempfile module creates a file that cannot be opened?
<p>I'm using the <code>tempfile</code> module and <code>imagemagick</code> and when i try to run this code:</p>

<pre><code>width = height = 100
temp_file = tempfile.NamedTemporaryFile()
canvas = "convert -size {}x{} canvas:black {}/canvas.png".format(scale_width, scale_height, temp_file.name)
os.system(canvas)
</code></pre>

<p>I get the following error:</p>

<blockquote>
  <p>convert: unable to open image
  <code>/var/folders/jn/phqf2ygs0wlgflgfvvv0ctbw0009tb/T/tmpeMcIuh/canvas.png':
  Not a directory @ error/blob.c/OpenBlob/2705. convert: WriteBlob
  Failed
  </code>/var/folders/jn/phqf2ygs0wlgflgfvvv0ctbw0009tb/T/tmpeMcIuh/canvas.png'
  @ error/png.c/MagickPNGErrorHandler/1630.</p>
</blockquote>

<p>What could be the problem?
I'm just trying to create a black image (resolution of 100x100) stored in a randomly generated temp file.</p>

<p>Thanks!</p>