note 112161 added to imagickpixel.getcolor

From: Date: Fri, 10 May 2013 21:27:50 +0000
Subject: note 112161 added to imagickpixel.getcolor
Groups: php.notes 
Request: Send a blank email to php-notes+get-194781@lists.php.net to get a copy of this message
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. ---- Server IP: 69.147.83.199 Probable Submitter: 93.184.73.10 ---- Manual Page -- http://php.net/manual/en/imagickpixel.getcolor.php Edit -- https://master.php.net/note/edit/112161 Del: integrated -- https://master.php.net/note/delete/112161/integrated Del: useless -- https://master.php.net/note/delete/112161/useless Del: bad code -- https://master.php.net/note/delete/112161/bad+code Del: spam -- https://master.php.net/note/delete/112161/spam Del: non-english -- https://master.php.net/note/delete/112161/non-english Del: in docs -- https://master.php.net/note/delete/112161/in+docs Del: other reasons-- https://master.php.net/note/delete/112161 Reject -- https://master.php.net/note/reject/112161 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#194781) next »