ImagickPixel::getColor

(PECL imagick 2.0.0)

ImagickPixel::getColorReturns the color

说锟斤拷

ImagickPixel::getColor ([ int $normalized = 0 ] ) : array

Returns the color described by the ImagickPixel object, as an array. If the color has an opacity channel set, this is provided as a fourth value in the list.

锟斤拷锟斤拷

normalized

Normalize the color values

锟斤拷锟斤拷值

An array of channel values, each normalized if TRUE is given as param. Throws ImagickPixelException on error.

锟斤拷锟斤拷

Example #1 Basic Imagick::getColor() usage

<?php

//Create an ImagickPixel with the predefined color 'brown'
$color = new ImagickPixel('brown');

//Set the color to have an alpha of 25%
$color->setColorValue(Imagick::COLOR_ALPHA64 256.0);

$colorInfo $color->getColor();

echo 
"Standard values".PHP_EOL;
print_r($colorInfo);

$colorInfo $color->getColor(true);

echo 
"Normalized values:".PHP_EOL;
print_r($colorInfo);

?>

锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�

Standard values
Array
(
    [r] => 165
    [g] => 42
    [b] => 42
    [a] => 0
)
Normalized values:
Array
(
    [r] => 0.64705882352941
    [g] => 0.16470588235294
    [b] => 0.16470588235294
    [a] => 0.25000381475547
)