def image_from_x(x):
 if isinstance(x, type(u'')):
  return image_from_path(x)
 if hasattr(x, u'read'):
  return image_from_data(x.read())
 if isinstance(x, (bytes, QImage)):
  return image_from_data(x)
 if isinstance(x, bytearray):
  return image_from_data(bytes(x))
 if isinstance(x, QPixmap):
  return x.toImage()
 raise TypeError((u'Unknown image src type: %s' % type(x)))

def image_from_x ( x ) : if isinstance ( x , type ( u'' ) ) : return image_from_path ( x ) if hasattr ( x , u'read' ) : return image_from_data ( x . read ( ) ) if isinstance ( x , ( bytes , QImage ) ) : return image_from_data ( x ) if isinstance ( x , bytearray ) : return image_from_data ( bytes ( x ) ) if isinstance ( x , QPixmap ) : return x . toImage ( ) raise TypeError ( ( u'Unknown image src type: %s' % type ( x ) ) )
create an image from a bytestring or a path or a file like object .