import  Image
import  sys
import  os

curdir
= " E:\\py\\WinPython-32bit-2.7.6.4\\study "

os.chdir(curdir)

def  processImage(infile):
    
try :
        im 
=  Image.open(infile)
    
except  IOError:
        
print   " Cant load " , infile
        sys.exit(
1 )
    i 
=  0
    mypalette 
=  im.getpalette()

    
try :
        
while   1 :
            im.putpalette(mypalette)
            new_im 
=  Image.new( " RGB " , im.size)
            new_im.paste(im)
            new_im.save(
' foo ' + str(i) + ' .bmp ' )

            i 
+=   1
            im.seek(im.tell() 
+   1 )

    
except  EOFError:
        
pass   #  end of sequence

if   __name__   ==   ' __main__ ' :
        processImage(
" 10.gif " )
        im
= Image.open( " foo0.bmp " )
        
print   " img info: " ,im.format,im.size