note 70156 added to function.imagecolorset
| From: | moxleystratton dot com at osu1 dot php dot net | Date: | Wed, 04 Oct 2006 22:59:21 +0000 |
| Subject: | note 70156 added to function.imagecolorset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-118069@lists.php.net to get a copy of this message | ||
If you want to convert a Color image to Grayscale without creating a blotchy image, use this color
calculation:
<?php
function imagetograyscale($im)
{
if (imageistruecolor($im)) {
imagetruecolortopalette($im, false, 256);
}
for ($c = 0; $c < imagecolorstotal($im); $c++) {
$col = imagecolorsforindex($im, $c);
$gray = round(0.299 * $col['red'] + 0.587 * $col['green'] + 0.114 *
$col['blue']);
imagecolorset($im, $c, $gray, $gray, $gray);
}
}
?>
----
Server IP: 64.71.164.2
Probable Submitter: 12.111.169.242
----
Manual Page -- http://www.php.net/manual/en/function.imagecolorset.php
Edit -- https://master.php.net/note/edit/70156
Del: integrated -- https://master.php.net/note/delete/70156/integrated
Del: useless -- https://master.php.net/note/delete/70156/useless
Del: bad code -- https://master.php.net/note/delete/70156/bad+code
Del: spam -- https://master.php.net/note/delete/70156/spam
Del: non-english -- https://master.php.net/note/delete/70156/non-english
Del: in docs -- https://master.php.net/note/delete/70156/in+docs
Del: other reasons-- https://master.php.net/note/delete/70156
Reject -- https://master.php.net/note/reject/70156
Search -- https://master.php.net/manage/user-notes.php