首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

ImagickPixel::getColor

(PECL imagick 2.0.0)

ImagickPixel::getColor — Returns the color

Description

代码语言:javascript
复制
array ImagickPixel::getColor ([ bool $normalized = false ] )

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.

Parameters

normalized

Normalize the color values

Return Values

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

Examples

Example #1 Basic Imagick::getColor() usage

代码语言:javascript
复制
<?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_ALPHA,?64?/?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);

?>

The above example will output:

代码语言:javascript
复制
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
)
    

← ImagickPixel::destroy

ImagickPixel::getColorAsString →

代码语言:txt
复制
 ? 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com