def identify_data(data):
 if (not isinstance(data, StringIO)):
  data = StringIO(data)
 img = Image.open(data)
 (width, height) = img.size
 fmt = img.format
 return (width, height, fmt)

def identify_data ( data ) : if ( not isinstance ( data , StringIO ) ) : data = StringIO ( data ) img = Image . open ( data ) ( width , height ) = img . size fmt = img . format return ( width , height , fmt )
identify the image in data .