title: Using Matplotlib imshow to show GIF image
body: <p>I need to show a background to a matplotlib plot using <code>ax.imshow()</code>. The background images that I will be using are GIF-images. Despite having PIL installed, the following code results in an error complaining that the Python Image Library (PIL) is not installed (which it is):</p>
  
  <pre><code>from pylab import imread
  im_file = open("test.gif")
  im_obj = imread(im_file)
  </code></pre>
  
  <p>Reading the image using PIL directly works better:</p>
  
  <pre><code>from PIL import Image
  import numpy
  img = Image.open("test.gif")
  img_arr = asarray(img.getdata(), dtype=numpy.uint8)
  </code></pre>
  
  <p>However, when reshaping the array, the following code does not work:</p>
  
  <pre><code>img_arr = img_arr.reshape(img.size[0], img.size[1], 3) #Note the number 3
  </code></pre>
  
  <p>The reason is that the actual color information is contained in a color table accessed through <code>img.getcolors()</code> or <code>img.getpalette()</code>.</p>
  
  <p>Converting all the images to PNG or another suitable format that results in RGB images when opening them with <code>imread()</code> or <code>Image.open()</code> is not an option. I could convert the images when needed using PIL but I consider that solution ugly. So the question is as follows: Is there a simple and fast (the images are 5000 x 5000 pixels) way to convert the GIF images to RGB (in RAM) so that I can display them using <code>imshow()</code>?</p>