Name

colorspace — type of colorspace

Synopsis

$image->Set(colorspace=>string)
$image->Get('colorspace')

Color reduction takes place in the RGB colorspace by default, but in certain cases you may get better results with a different colorspace. string corresponds to one of several color models. The values we are interested in are:

  • RGB: red, green, blue

  • Gray (not “Grey”): grayscale

  • Transparent: RGB with retained transparent colors (if any)

  • YIQ: a color model used by NTSC

  • YUV: Luminance, Chrominance used by MPEG

  • YCbCr: a variant of YUV that gives good results with skin tones

  • CMYK: Cyan, Magenta, Yellow, Black

The colorspace attribute must be followed by a Quantize( ) method call for the change to take effect. The attribute may also be set directly from the Quantize( ) call, as in:

$image->Quantize(colorspace=>'Gray');

Get Programming Web Graphics with Perl and GNU Softwar now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.