def quantize_image(img, max_colors=256, dither=True, palette=u''):
 img = image_from_data(img)
 if img.hasAlphaChannel():
  img = blend_image(img)
 if (palette and isinstance(palette, basestring)):
  palette = palette.split()
 return imageops.quantize(img, max_colors, dither, [QColor(x).rgb() for x in palette])

def quantize_image ( img , max_colors = 256 , dither = True , palette = u'' ) : img = image_from_data ( img ) if img . hasAlphaChannel ( ) : img = blend_image ( img ) if ( palette and isinstance ( palette , basestring ) ) : palette = palette . split ( ) return imageops . quantize ( img , max_colors , dither , [ QColor ( x ) . rgb ( ) for x in palette ] )
quantize the image to contain a maximum of max_colors colors .