note 127973 added to imagick.colorizeimage

From: Date: Thu, 01 Dec 2022 13:09:24 +0000
Subject: note 127973 added to imagick.colorizeimage
Groups: php.notes 
Request: Send a blank email to php-notes+get-219929@lists.php.net to get a copy of this message
The solution published by "olav at redwall dot ee " was adding a black surround outside each non-transparent shape. Here is my improved version : <?php public function colorize($color, $alpha = 1) { $geometry = $this->getImageGeometry(); $width = $geometry['width']; $height = $geometry['height']; $draw = new ImagickDraw; $draw->setFillColor($color); $draw->rectangle(0, 0, $width, $height); $temporary = new Imagick; $temporary->setBackgroundColor(new ImagickPixel('transparent')); $temporary->newImage($width, $height, new ImagickPixel('transparent')); $temporary->setImageFormat('png32'); $temporary->drawImage($draw); $temporary->compositeImage($this, Imagick::COMPOSITE_COPYOPACITY, 0, 0); $this->setImageArtifact('compose:args', ($alpha * 100) . '%,100%'); $this->compositeImage($temporary, Imagick::COMPOSITE_DISSOLVE, 0, 0); } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.159.161 (proxied: 2a04:cec0:1105:2f19:5c71:f98d:4369:e23b) ---- Manual Page -- https://php.net/manual/en/imagick.colorizeimage.php Edit -- https://main.php.net/note/edit/127973 Del: integrated -- https://main.php.net/note/delete/127973/integrated Del: useless -- https://main.php.net/note/delete/127973/useless Del: bad code -- https://main.php.net/note/delete/127973/bad+code Del: spam -- https://main.php.net/note/delete/127973/spam Del: non-english -- https://main.php.net/note/delete/127973/non-english Del: in docs -- https://main.php.net/note/delete/127973/in+docs Del: other reasons-- https://main.php.net/note/delete/127973 Reject -- https://main.php.net/note/reject/127973 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#219929) next »