HomeImagickImagickDrawImagickPixelImagick Pixel IteratorImagick KernelTutorial Source codeReport an issue
Category
Example

get color value quantum

← getColorValue   getHSL →
Gets the quantum value of a color in the ImagickPixel. Return value is a float if ImageMagick was compiled with HDRI, otherwise an integer.
Red: 32896 Green: 1285 Blue 65535 Alpha: 65535
$color = new \ImagickPixel('rgb(128, 5, 255)');
$colorRed = $color->getColorValueQuantum(\Imagick::COLOR_RED);
$colorGreen = $color->getColorValueQuantum(\Imagick::COLOR_GREEN);
$colorBlue = $color->getColorValueQuantum(\Imagick::COLOR_BLUE);
$colorAlpha = $color->getColorValueQuantum(\Imagick::COLOR_ALPHA);
return sprintf(
    "Red: %s Green: %s  Blue %s Alpha: %s",
    $colorRed,
    $colorGreen,
    $colorBlue,
    $colorAlpha
);