I am using the following coding to create a image on the fly, but for some reason it's not turning out well on my server as it did on my computer:-
<?php
// Set the static variables (discussed in steps 2 and 3)
$filename = md5("capbiker");
$font_file = "/fonts/timesbd.ttf";//$_SERVER['DOCUMENT_ROOT']."/path/TIMESBD.ttf"; //$_SERVER['DOCUMENT_ROOT']."/path/verdana.ttf";
$font_file2 = "/fonts/times.ttf";//$_SERVER['DOCUMENT_ROOT']."/path/TIMES.ttf";
$font_file3 = "/fonts/verdana.ttf";//$_SERVER['DOCUMENT_ROOT']."/path/verdana.ttf";
$font_size = 30;
$font_size1 = 20;
$font_size2 = 10;
$angle = 0;
/*$dh = opendir(".");
while (false !== ($file = readdir($dh)))
{
if (preg_match('/\.jpg$/i', $file) and $file != "testing2.jpg") // sanning for .jpg files only and stopping avatar.jpg being loaded (you will run into errors if this isnt here)
{
$filelist[] = $file;
}
}
srand((double)microtime()*1000000);
$picnum = rand(0, sizeof($filelist) - 1);
$img = $filelist[$picnum];*/
$img = "J.jpg";
$thime_different = 0;
$c_time = time() - $time_different;
$time = mktime(15, 00, 00, 10, 29, 2004);
$days = sprintf("%.0d",($time - $c_time) / 86400);
$hours = sprintf("%.0d",($time - $c_time) / 3600);
$mins = sprintf("%.0d",($time - $c_time) / 60);
$secs = sprintf("%.0d",($time - $c_time));
$title = "The White Room Count Down\n\n";
$text = "Days Remaing: $days\n";
$text2 = "Hours Remaining: $hours\n";
$text3 = "Minutes Remaining: $mins\n";
$text4 = "Seconds Remaing: $secs\n\n"; //"© [url]www.liminality.org[/url]";
$name = "The White Room: " . date("G:i - d", $time) . "th " . date("F Y", $time);
$text6 = "This banner is updated every hour";*/
// The dummy image hack (discussed in step 1)
$im_size = getimagesize($img);
$image_width = $im_size[0];
$image_height = $im_size[1];
$im = imagecreate($image_width, $image_height);
$white = imagecolorallocate($im, 255, 255, 255);
$im2 = imagecreatefromjpeg($img);
imagecopy($im, $im2, 0, 0, 0, 0, $image_width, $image_height);
imagedestroy($im2);
// Position the text (discussed in step 3)
$bounding_box = imagettfbbox($font_size, 0, $font_file, $text);
$x_start = $image_width - $bounding_box[2] - $bounding_box[0] - 170;
$y_start = $image_height - 150;
$x_start1 = $image_width - $bounding_box[2] - $bounding_box[0] - 145;
$y_start1 = $image_height - 120;
$x_start2 = $image_width - $bounding_box[2] - $bounding_box[0] - 145;
$y_start2 = $image_height - 100;
$x_start3 = $image_width - $bounding_box[2] - $bounding_box[0] - 145;
$y_start3 = $image_height - 80;
$x_start4 = $image_width - $bounding_box[2] - $bounding_box[0] - 145;
$y_start4 = $image_height - 60;
$x_start5 = $image_width - $bounding_box[2] - $bounding_box[0] - 145;
$y_start5 = $image_height - 40;
$x_start6 = $image_width - $bounding_box[2] - $bounding_box[0] - 145;
$y_start6 = $image_height - 10;
// Write the text to the image
imagettftext($im, $font_size, $angle, $x_start, $y_start, $white, $font_file, $title);
imagettftext($im, $font_size1, $angle, $x_start1, $y_start1, $white, $font_file2, $name);
imagettftext($im, $font_size1, $angle, $x_start2, $y_start2, $white, $font_file2, $text);
imagettftext($im, $font_size1, $angle, $x_start3, $y_start3, $white, $font_file2, $text2);
imagettftext($im, $font_size1, $angle, $x_start4, $y_start4, $white, $font_file2, $text3);
imagettftext($im, $font_size1, $angle, $x_start5, $y_start5, $white, $font_file2, $text4);
imagettftext($im, $font_size2, $angle, $x_start6, $y_start6, $white, $font_file3, $text6);
// Create and then destroy the image (discussed in steps 5 and 6)
header("Content-type: image/jpeg");
imagejpeg($im);
//imagejpeg($im, "/home/looneysb/public_html/wr_banners/testing2.jpg");
imagedestroy($im);
?>
Until I can get it sorted out I have removed the text on in. But to view what is actually happening then click here
cap