note 36489 added to function.imagecolorclosest
| From: | Vikrant Korde | Date: | Sat, 11 Oct 2003 12:10:51 +0000 |
| Subject: | note 36489 added to function.imagecolorclosest | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-58242@lists.php.net to get a copy of this message | ||
This functuion is useful when you are dealing with previously present images like .png, .jpg, etc.
You can use this function for writing a text on the image.
For me the function imagecolorallocate() was returning the -1 value. after lot of RnD and site
search i found a function use of imagecolorclosest(). This solved my problem of writing the text on
the image with customised color.
Actually previously it was writing on the image but the color was not distinct. It was using the
same color as of that background image.
The following code segment was fine with me.
header ("Content-type: image/jpeg");
$im = imagecreatefromjpeg("BlankButton.jpg");
$white = imageColorClosest($im, 255,255,255);
// this is for TTF fonts
imagettftext ($im, 20, 0, 16, 30, $white, "/usr/X11R6/lib/X11/fonts/TTF/luximb.ttf",
"Vikrant");
//this is for notmal font
imagestring($im, 4, 0,0,"Korde", $white);
imagejpeg($im,"",150);
imagedestroy ($im);
----
Manual Page -- http://www.php.net/manual/en/function.imagecolorclosest.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+36489
Delete -- http://master.php.net/manage/user-notes.php?action=delete+36489&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+36489&report=yes
Search -- http://master.php.net/manage/user-notes.php