title: Saving numpy.ndarray in python as an image
body: <pre><code>b=ndimage.gaussian_filter(imagefile,5)   
  </code></pre>
  
  <p>Being new to python, not able to figure this out.<br>
  how to save <code>b</code> as an image, <code>b</code> is of  type 'numpy.ndarray'?   </p>
  
  <p>Tried these,<br>
  1.</p>
  
  <pre><code>im = Image.fromarray(b)   
  im.save("newfile.jpeg")   
  </code></pre>
  
  <p><code>Error: TypeError("Cannot handle this data type")</code></p>
  
  <p>2.</p>
  
  <pre><code>imsave('newfile.jpg', b)
  </code></pre>
  
  <p><code>Error: ValueError: 'arr' does not have a suitable array shape for any mode.</code></p>
  
  <p>Which is the right way to save an <code>ndarray</code> into an image?</p>
  
  <p>EDIT:</p>
  
  <p>Solved: </p>
  
  <pre><code>im = Image.fromarray(b)    
  </code></pre>
  
  <p><code>im.save('newfile.jpeg')</code> worked, The way I was loading the image was wrong,</p>
  
  <pre><code>file = Image.open("abc.jpg")      
  imagefile = file.load()     
  </code></pre>
  
  <p>// I was using imagefile after loading, which was not giving proper shape to reconstruct the image.</p>
  
  <p>// Instead If I use file (i.e. directly after opening, I can save by above method)</p>