How to change gif file to png file using python pil
Question: this is my code :

    
    
    import Image,glob
    
    files = glob.glob("/small/*.gif") 
    
    for imageFile in files:
        print "Processing: " + imageFile
        try:
            im = Image.open(imageFile)
            im.save( "/small_/", "png" )
        except Exception as exc:
            print "Error: " + str(exc)
    

but it show error :

    
    
      File "f.py", line 13
        im.save( "/small_/", "png" )
         ^
    SyntaxError: invalid syntax
    

so what can i do ,

thanks

**updated:**

    
    
    import Image,glob,os
    
    files = glob.glob("small/*.gif") 
    
    for imageFile in files:
        filepath,filename = os.path.split(imageFile)
        filterame,exts = os.path.splitext(filename)
        print "Processing: " + imageFile,filterame
        im = Image.open(imageFile)
        im.save( 'small_/'+filterame+'.png','PNG')
    


Answer: Try copy and pasting your code in here back into your editor, it works
perfectly fine for me. You seem to have some non-printable characters in there
or something similar.

Also, have a look at the [PIL
documentation](http://www.pythonware.com/library/pil/handbook/image.htm),
`save` needs a filename or fileobject, not a folder.

