title: Parse folder with images into (m, n) shaped numpy array
body: <p>I am trying to parse a folder with images into a numpy array.  I want to obtain an array which looks like this:</p>
  
  <pre><code>import numpy as np
  from sklearn.datasets import fetch_mldata
  
  #load 70,000 MNIST images (28 X 28 pixels)
  mnist = fetch_mldata("MNIST original")
  X = mnist.data
  
  print X.shape 
  </code></pre>
  
  <p>Desired output:</p>
  
  <pre><code>(70000L, 784L)
  </code></pre>
  
  <p>This is what I tried:</p>
  
  <pre><code>from PIL import Image                                                            
  import numpy                                                                     
  import matplotlib.pyplot as plt                                                  
  import glob
  
  #I have two colour images, each 64 X 64 pixels, in the folder
  imageFolderPath = 'C:\\Users\\apples\\Desktop\\t-sne\\pics'
  imagePath = glob.glob(imageFolderPath+'/*.JPEG') 
  
  im_array = numpy.array( [numpy.array(Image.open(imagePath[i])) for i in range(len(imagePath))] )
  
  print im_array.shape
  </code></pre>
  
  <p>But it produces the following output:</p>
  
  <pre><code>(2L, 64L, 64L, 3L)
  </code></pre>
  
  <p>How can I obtain an array with the following dimensions:</p>
  
  <pre><code>(m, n)
  </code></pre>