#native_company# #native_desc#
#native_cta#

Write Text to the Image

By Jeff Espiritu
on October 26, 2004

Version: 1

Type: Function

Category: Graphics

License: GNU General Public License

Description: Write a text to your image without altering the image itself.

Normally if you have an exclusive pictures you normally place your domain name as a symbol that you own the picture, but if you have hundred or more pictures it will be time consuming adding a text on each of the pictures.
This simple script will do the job for you by adding text in the top location of the picture once called and will not alter the picture itself, so you can change the text in the image anytime.
Example: <img src=”img.php?imgfile=image.jpg&text=YOURTEXTHERE”> )

<?php
/*
Created by http://smallcapitalbusiness.com

Other Scripts we made:
 - Traffic Exchange Link (The New Generation)
 - Simply FAQ Script
 - Write Text to the Image
 - Image Resizer
 - Simple Web Monitoring
 - Capture TGP New listing
 - Exit Popup Exchange Service
 - Domain Redirection Service
 - TGP or Thumbnail Gallery Post

GNU : Do not remove our signature at the bottom page
*/

//=========== change the text to display in the image
//$text = 'mydomain.com';
//$imgfile="smp.jpg";
$font = 'arial.ttf';
$ext=substr($imgfile,-3);
$ext=strtolower($ext);

if($ext=="jpg" || $ext=="jpe") $im=@imagecreatefromjpeg("$imgfile");
elseif ($ext=="gif") $im=@imagecreatefromgif("$imgfile"); 
else {print "Unknown image format"; exit;}

 if (!$im) { /* See if it failed */
       $im = ImageCreate (150, 30); /* Create a blank image */
       $bgc = ImageColorAllocate ($im, 255, 255, 255);
       $tc  = ImageColorAllocate ($im, 0, 0, 0);
       ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc); 
       /* Output an errmsg */
       ImageString($im, 1, 5, 5, "Error loading $imgfile", $tc); 
	return $im;
   }

$x=imagesx($im);
$y=imagesy($im);
$fontsize=$x/20;
$fontsize=floor($fontsize);
if($fontsize<10) $fontsize=10;

$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);

imagettftext($im, $fontsize, 0, 12, $fontsize+8, $black, $font, $text);
imagettftext($im, $fontsize, 0, 10, $fontsize+6, $white, $font, $text);

imagettftext($im, 10, 0, 12, $y-8, $white, $font, "Powered by SmallCapitalBusiness.com");
imagettftext($im, 10, 0, 10, $y-7, $black, $font, "Powered by SmallCapitalBusiness.com");
if($ext=="gif") 
	{
	header("Content-type: image/gif");
	imagegif($im);
	}
else
	{
	header("Content-type: image/jpeg");
	imagejpeg($im);

	}
imagedetroy($im);
?>