img.verify() # to veify if its an img img.close() #to close img and free memory space except (IOError, SyntaxError) as e: <-- here's the error