def image_from_data(data):
 if isinstance(data, QImage):
  return data
 i = QImage()
 if (not i.loadFromData(data)):
  raise NotImage(u'Not a valid image')
 return i

def image_from_data ( data ) : if isinstance ( data , QImage ) : return data i = QImage ( ) if ( not i . loadFromData ( data ) ) : raise NotImage ( u'Not a valid image' ) return i
create an image object from data .