Here is a snippet I modified. Basically it's to set transparent text over a background:
I get a premature end of script headers when I don't comment out the imagecopy(). Any ideas? I'm new to the GD library... in fact I have yet to find a decent tutorial online that actually EXPLAINS what everything does... anyone have any good tutorials as well?
- "Delightfully confusing..." raves The New York Times
-kas
Code:
<?
header('Content-type: image/jpeg');
$im = ImageCreateFromJpeg("bg.jpg");
$im_w = imagesx($im); // Get the image width
$im_h = imagesy($im); // Get the image height
$col = imagecolorallocate($im, 0, 0, 0);
imagesetpixel($im,$im_w-1,0,$col);
$new = imagecreate($im_w,$im_h); // Create a buffer
$index = imagecolorat($im,$im_w-1,0); // Get the color at that pixel
$rgb = imagecolorsforindex($im,$index); // Get the index of that color
$r = $rgb["red"]; // Get the red value
$g = $rgb["green"]; // Get the green value
$b = $rgb["blue"]; // Get the blue value
$color = imagecolorallocate($new,$r,$g,$b); // Allocate this color on the buffer
$copy = imagecopy($new,$im,0,0,0,0,$im_w,$im_h); // Copy the old image onto the buffer
$text = imagettftext($new,20,0,10,10,$color,"c:\windows\fonts\arial.ttf","test"); // Draw the text
$merge = imagecopymerge($im,$new,0,0,0,0,$im_w,$im_h,50); // Copy the buffer back onto the original image
imagedestroy($new); // Destroy the buffer
imagejpeg($im);
?>
I get a premature end of script headers when I don't comment out the imagecopy(). Any ideas? I'm new to the GD library... in fact I have yet to find a decent tutorial online that actually EXPLAINS what everything does... anyone have any good tutorials as well?
- "Delightfully confusing..." raves The New York Times
-kas