Help needed in saving Image
Posted: Thu Jun 22, 2006 12:01 am
Hi,
I'm trying out this PHP code to create an image using the following code.
This works fine.
Now what I did was save this in a php file named draw.inc.php as a function and return the image refernece. This PHP is included in another php file called saveImage.php which calls this function and with the reference tries to save it in a folder. Now this is not happening....
What do I do?!! I have no idea. I'm trying this out in my local machine running a webserver. How do I do this..
Please help me out with this.
I don't know how to attach the zip to this post and so am providing the code in the post itself
//File name : draw.inc.php
//Filename : save.php
I'm really in a soup here.. to finish this work ASAP
I'm trying out this PHP code to create an image using the following code.
Code: Select all
<?php
header ("Content-type: image/png");
$im = @imagecreatetruecolor(50, 100)
or die("Cannot Initialize new GD image stream");
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "A Simple Text String", $text_color);
imagejpeg($im);
imagedestroy($im);
?>Now what I did was save this in a php file named draw.inc.php as a function and return the image refernece. This PHP is included in another php file called saveImage.php which calls this function and with the reference tries to save it in a folder. Now this is not happening....
What do I do?!! I have no idea. I'm trying this out in my local machine running a webserver. How do I do this..
Please help me out with this.
I don't know how to attach the zip to this post and so am providing the code in the post itself
//File name : draw.inc.php
Code: Select all
<?php
function drawFromXML()
{
header ("Content-type: image/png");
$im = @imagecreatetruecolor(50, 100)
or die("Cannot Initialize new GD image stream");
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "A Simple Text String", $text_color);
imagejpeg($im);
imagedestroy($im);
return $img;
}
?>//Filename : save.php
Code: Select all
<?php
include_once 'draw.inc.php';
$img = drawFromXML();
$str = "CARD-" . md5(rand() * rand() + " ");
$fileName = secure_tmpname('.jpg', $str, '.');
echo"$fileName";
imagejpeg($img,$fileName1, $GLOBALS['fcard_config']['jpeg_quality']);
echo "<img src='".$fileName1.".jpeg'>";
?>I'm really in a soup here.. to finish this work ASAP