note 78726 added to function.imagecolorallocate
| From: | Ludo at osu1 dot php dot net | Date: | Wed, 24 Oct 2007 21:35:41 +0000 |
| Subject: | note 78726 added to function.imagecolorallocate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131709@lists.php.net to get a copy of this message | ||
When working on an existant GIF images, if the number of different colours has reached the limits of
the GIF format, imagecolorallocate will not use to the colour you ask her within the parameters, she
will apply black !
That's a problem when generating images "on-the-fly" with many manipulations, from a
GIF image.
To go round the problem, you have to convert the GIF image into a PNG one, and then you can work on
the PNG and everything will be ok.
For example :
<?php
// first, convert into a PNG image
$handle = imagecreatefromgif('my_image.gif');
imagepng($handle, 'my_image.png');
imagedestroy($handle);
// then, you can work on it
$handle = imagecreatefrompng('my_image.png');
/*
* work on the image
*/
imagegif($handle);
?>
----
Server IP: 217.174.196.197
Probable Submitter: 85.68.236.192
----
Manual Page -- http://www.php.net/manual/en/function.imagecolorallocate.php
Edit -- https://master.php.net/note/edit/78726
Del: integrated -- https://master.php.net/note/delete/78726/integrated
Del: useless -- https://master.php.net/note/delete/78726/useless
Del: bad code -- https://master.php.net/note/delete/78726/bad+code
Del: spam -- https://master.php.net/note/delete/78726/spam
Del: non-english -- https://master.php.net/note/delete/78726/non-english
Del: in docs -- https://master.php.net/note/delete/78726/in+docs
Del: other reasons-- https://master.php.net/note/delete/78726
Reject -- https://master.php.net/note/reject/78726
Search -- https://master.php.net/manage/user-notes.php