php8.5
Home/ Manual/ imagick / imagickpixel/ ImagickPixel::getColorAsString

ImagickPixel::getColorAsString

PHP function Edit on GitHub ✎

(PECL imagick 2 >= 2.1.0, PECL imagick 3)

Returns the color as a string

Description

ImagickPixel::getColorAsString(): string

Returns the color of the ImagickPixel object as a string.

Parameters Parameters

Return Values

Returns the color of the ImagickPixel object as a string.

Examples

Basic Imagick::getColorAsString() usage

php
<?php

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

$color->setColorValue(Imagick::COLOR_ALPHA, 64 / 256.0);

$colorInfo = $color->getColorAsString();

print_r($colorInfo);
?>

The above example will output:

output
rgb(165,42,42)

Notes

Note

This function does not return the alpha value of the color in the string.

Source: reference/imagick/imagickpixel/getcolorasstring.xml · from the official PHP manual (php/doc-en)