note 48399 added to function.imagecolorallocate
| From: | aaron at parecki dot com | Date: | Wed, 22 Dec 2004 10:10:50 +0000 |
| Subject: | note 48399 added to function.imagecolorallocate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-82170@lists.php.net to get a copy of this message | ||
This will let you tint an image to any specific color. The blacks of the source image become your
specified color, and the whites remain white. Works best for colorizing greyscale images.
<?php
$r = 224;
$g = 192;
$b = 0;
$source_file = "picture.jpg";
$im_src = ImageCreateFromJpeg($source_file);
$im_tint = ImageCreate(imagesx($im_src),imagesy($im_src));
for ($c = 0; $c < 255; $c++) {
ImageColorAllocate($im_tint, max($r,$c), max($g,$c), max($b,$c));
}
ImageCopyMerge($im_tint,$im_src,0,0,0,0, imagesx($im_src), imagesy($im_src), 100);
ImageDestroy($im_src);
header("Content-type: image/jpeg");
imagejpeg($im_tint);
?>
----
Manual Page -- http://www.php.net/manual/en/function.imagecolorallocate.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48399
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48399&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48399&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48399&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48399&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48399&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48399&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48399&report=yes
Search -- http://master.php.net/manage/user-notes.php