<?php
/*------------------------------------------------------*/
/* Crimages.php */
/* Written by Nitchimon nitchimon@yahoo.com */
/* AIM: nitchimon */
/* Purpose: To allow a watermark to be placed */
/* within an image on the fly. Thus to */
/* protect the copyright of the image. */
/* Date: October 2003 */
/* */
/* To do: */
/* 1) add a module into the ADMIN section to make the CRTEXT a global variable */
/* 2) have a pattern of CRTEXT within the image instead of just 1 line */
/* 3) changing or passing where the fonts are located instead of hard coded */
/* could be part of the ADMIN mod? */
/* 3) got an idea or MOD? Contact me and I'll update it with full credits */
/* */
/* This was originally taken from the PHP.NET site */
/* and modified by me. It was an example file */
/*------------------------------------------------------*/
$crtext = STORE_NAME ;
// specify the file name - you can use a full path, or "../../" type stuff here
// if the image is not in the same directory as this code file
////$image = imagecreatefromjpeg("$imagedir/$imagefile");
$image = imagecreatefromjpeg("$imagefile");
// specify the font size
$font_size = 20;
// in this case, the color is white, but you can replace the numbers with the RGB values
// of any color you want
$color = imagecolorallocate($image, 255,255,255);
// make our drop shadow color
$black = imagecolorallocate($image, 0,0,0);
// and now we do the overlay - the layers of text start top to bottom, so
// the drop shadow comes first
// $image - the base image file we specified above
// $font_size - Well duh. Its the size of the font
// 0 - the angle of the text - we don't want an angle, so we leave it at 0
// 56 - pixels to the right from the leftmost part of the image
// 100 - pixels down from the top of the image
// $black - the color we defined above
// "../fonts/ARIALBD.TTF" - the location on the server that the font can be found
// "Test Text" - the text we're overlaying - you can also use a variable here
// Becaus the function likes the complete path to things, I added the REALPATH function
// so it will give the function the right informaiton, otherwise BOOM! it no work no more.
ImageTTFText ($image, $font_size,0, 56, 100, $black, realpath("fonts/fransis.ttf"),"$crtext");
// Display the image
imagejpeg($image);
// Now destroy the image buffer
// otherwise you could theoretically run out of memory
// with all these image buffers all over the place.
imagedestroy($image);
?>