Page 1 of 1

Help needed in saving Image

Posted: Thu Jun 22, 2006 12:01 am
by hari-kj
Hi,

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);


?>
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

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

Posted: Thu Jun 22, 2006 12:14 pm
by RobertGonzalez
Are you getting any error reports? Do you have error_reporting set to E_ALL and display_errors on? What exactly is the problem?

Posted: Fri Jun 23, 2006 7:13 am
by hari-kj
Hi,

Thanks for the reply. I'm not sure what happened, but now its working : )

YAAY !!!

I'm actually doing this so that I can capture a flash image that user's create on the fly and save it as an jpeg.

If I use the imagecreatetruecolor and the imagejpeg methods, still the jpeg's resolution is not that good if I were to use the jpeg as a wallpaper or a logo or something like that. Is there some way to increase the resolution, or make the final image very smooth and good as it would appear on flash. Or is there some other way I can take a quick screen grab of the flash movie through PHP and save it.

Any help would be gladly used :)