Hello,
I have this php code with GD library functions and it is not working correctly.
http://xlouloux.net84.net/hello.php - here's the link, all it says it that it has errors.
I have put the png and the ttf files in the same directory as the php.
Please help, thanks.
__________________________________________________ ______
PHP Code:
<?php
header('content-type: image/png');
// ---------- DO NOT EDIT ANYTHING ABOVE ----------
$name = "Lou";
$image = "IMAG0018.png";
$due_day = 17;
$due_month = 11;
$due_year = 2013;
$font = 'comic.ttf';
$fontsize = 12;
$slant = 0;
$margin_left = 40;
$margin_top = 250;
// shadow true or false
$shadow = true;
$shadow_left = 2;
$shadow_top = 2;
// ignore these, go down 17 lines to change the font colour
$image = imagecreatefrompng($image);
$red = ImageColorAllocate($image, 255, 0, 0);
$green = ImageColorAllocate($image, 0, 153, 0);
$blue = ImageColorAllocate($image, 0, 0, 255);
$black = ImageColorAllocate($image, 0, 0, 0);
$white = ImageColorAllocate($image, 255, 255, 255);
$yellow = ImageColorAllocate($image, 255, 255, 0);
$aqua = ImageColorAllocate($image, 0, 255, 255);
$fuschia = ImageColorAllocate($image, 255, 0, 255);
$grey = ImageColorAllocate($image, 153, 153, 153);
$lightgrey = ImageColorAllocate($image, 187, 187, 187);
$silver = ImageColorAllocate($image, 204, 204, 204);
$teal = ImageColorAllocate($image, 0, 153, 153);
$lime = ImageColorAllocate($image, 0, 255, 0);
$navy = ImageColorAllocate($image, 0, 0, 153);
$purple = ImageColorAllocate($image, 153, 0, 153);
$maroon = ImageColorAllocate($image, 153, 0, 0);
$olive = ImageColorAllocate($image, 153, 153, 0);
// don't forget the font colour
$fontcolor = $red;
// ---------- DO NOT EDIT ANYTHING BELOW ----------
// time variables
$today = mktime();
$due = mktime(0, 0, 0, $due_month, $due_day, $due_year);
$total_pregnancy = (60*60*24*280);
// get timecode for time left in pregnancy
$diff = ($total_pregnancy - ($due - $today));
// calculate weeks
$week = (60*60*24*(365/52));
$weeks = intval($diff / $week);
$diff = $diff % $week;
// calculate days
$day = (60*60*24);
$days = intval($diff / $day);
$diff = $diff % $day;
// text to superimpose onto the image
$text = sprintf("%s is %s weeks and %s days pregnant", $name, $weeks, $days);
// make image
if ($shadow) {imagettftext($image, $fontsize, $slant, $margin_left+$shadow_left, $margin_top+$shadow_top, $lightgrey, $font, $text); }
imagettftext($image, $fontsize, $slant, $margin_left, $margin_top, $fontcolor, $font, $text);
// display image
imagepng($image);
// all done...
imagedestroy($image);
?>
__________________________________________________ ______