title: How can I create a PNG image file from a list of pixel values in Python?
body: <p>I can generate a list of pixel values from an existing image file using a procedure like the following:</p>
  
  <pre><code>from PIL import Image
  image = Image.open("test.png")
  pixels = list(image.getdata())
  width, height = image.size
  pixels = [pixels[i * width:(i + 1) * width] for i in xrange(height)]
  </code></pre>
  
  <p>How could I convert this list of pixel values back to an image file?</p>