downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

ImagickPixel::getColorAsString> <ImagickPixel::destroy
[edit] Last updated: Fri, 17 May 2013

view this page in

ImagickPixel::getColor

(PECL imagick 2.0.0)

ImagickPixel::getColorReturns the color

Descrição

array ImagickPixel::getColor ([ bool $normalized = false ] )
Aviso

Esta função não está documentada; somente a lista de argumentos está disponível.

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.

Parâmetros

normalized

Normalize the color values

Valor Retornado

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



add a note add a note User Contributed Notes ImagickPixel::getColor - [1 notes]
up
0
roman
7 days ago
In case you use default un-normalized getColor value the alpha value will always be either 0 or 1.

If you want to use real full-range 0-1 alpha channel on your 24bit transparent images use the alpha value from the normalized one, even if you use the rest of unnormalized data.

To copy a 24bit png with real alpha transparency, you would have to do this:
<?php

$im
=new Imagick( 'image.png' );
$iterator=$im->getPixelIterator();
foreach (
$iterator as $row=>$pixels) {
    foreach (
$pixels as $column => $pixel ){
       
$un_color=$pixel->getColor(); //unnormalized color
       
$nor_color=$pixel->getColor(true); //normalized color
       
$pixel->setColor('rgba('.$un_color['r'].','.$un_color['g'].','.$un_color['b'].','.$nor_color['a'].')');
    }
}
?>

If you use 'a' (alpha) value from the unnormalized color there will only be binary transparency.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites