I can successfully get an image an add text to it but I cannot save the image.
Here's a stripped down version of my code
PHP Code:
<?php
require "db.php";
$getecard = mysql_query("SELECT * FROM ecards WHERE ecardID='".$_POST['ecardID']."' ")or die(mysql_error());
$ecard = mysql_fetch_array($getecard);
$getcat = mysql_query("SELECT * FROM Category WHERE catID='".$ecard['catID']."' ")or die(mysql_error());
$cat = mysql_fetch_array($getcat);
// load the image from the file specified:
$im = imagecreatefrompng("./images/".$cat['path']."/".$ecard['image_name'].".png");
// if there's an error, stop processing the page:
if(!$im)
{
die("");
}
$color1 = $ecard['color1'];
$color2 = $ecard['color2'];
$color3 = $ecard['color3'];
// define some colours to use with the image
$color = imagecolorallocate($im, $color1,$color2,$color3);
// get the width and the height of the image
$width = imagesx($im);
$height = imagesy($im);
// draw a black rectangle across the bottom, say, 20 pixels of the image:
//imagefilledrectangle($im, 0, ($height-20) , $width, $height, $black);
// now we want to write in the centre of the rectangle:
$font = 4; // store the int ID of the system font we're using in $font
//line 1
$message1 = "".$_POST['message1'].""; // store the text we're going to write in $text
// calculate the left position of the text:
$Pos1 = ( $width - imagefontwidth($font)*strlen($message1) )/2.2;
// finally, write the string:
imagestring($im, $font, $Pos1, $height-140, $message1, $color);
//line 2
$message2 = "".$_POST['message2'].""; // store the text we're going to write in $text
// calculate the left position of the text:
$Pos2 = ( $width - imagefontwidth($font)*strlen($message2) )/2.2;
// finally, write the string:
imagestring($im, $font, $Pos2, $height-120, $message2, $color);
Header('Content-type: image/png');
// output the image as a png
imagepng($im);
// tidy up
imagedestroy($im);
Here's the site
http://ecards.zeeblo.com/ecards/ecard_list.php