Jump to content

Hello with this script, i get error log errors.


DigitalGuard

Recommended Posts

Hello,

 

I wrote this script to write on the image, and it works but its generating errorlog. Can any1 tell me what im doing wrong please.

 

Here is my error log.

[05-Aug-2009 16:11:54] PHP Warning:  imagecreatefromjpeg(./imagehfw/hfw.jpg) [<a href='function.imagecreatefromjpeg'>function.imagecreatefromjpeg</a>]: failed to open stream: No such file or directory in /home1/username/public_html/folder1/folder2/tested.php on line 16
[05-Aug-2009 16:11:54] PHP Warning:  imagecolorallocate(): supplied argument is not a valid Image resource in /home1/username/public_html/frolder1/folder2/tested.php on line 21
[05-Aug-2009 16:11:54] PHP Warning:  imagecolorallocate(): supplied argument is not a valid Image resource in /home1/username/public_html/folder1/folder2/tested.php on line 22
[05-Aug-2009 16:11:54] PHP Warning:  imagettftext() expects parameter 1 to be resource, boolean given in /home1/username/public_html/folder1/folder2/tested.php on line 23
[05-Aug-2009 16:11:54] PHP Warning:  imagettftext() expects parameter 1 to be resource, boolean given in /home1/username/public_html/folder1/folder2/tested.php on line 24
[05-Aug-2009 16:11:54] PHP Warning:  imagepng(): supplied argument is not a valid Image resource in /home1/username/public_html/folder1/folder2/tested.php on line 28

 

 

and here is my script

 

<?
header ("Content-type: image/png");
$today = date("M d, Y"); 
$string1 = "write  ";
$string = $string1.$today;
$web = "websitename";
                                       
$fontsize  = 10.5;
$fontsize1 = 11;
$angle = 0;
$font2  = 2;
$fontname = "../fonts/times.ttf";
$width  = ImageFontWidth($font)* strlen($string) ;
$height = ImageFontHeight($font) ; 

$im = ImageCreateFromjpeg("../imagehfw/hfw.jpg"); 
$x=0;
$x1=0;
$y=65;
$y1=80;
$background_color = imagecolorallocate ($im, 255, 255, 255); //white background
$text_color = imagecolorallocate ($im, 0, 0,0);//black text
imagettftext($im, $fontsize, $angle, $x, $y, $black, $fontname, $string);
imagettftext($im, $fontsize1, $angle, $x1, $y1, $black, $fontname, $web);



imagepng ($im);
?>

 

 

Can any one please let me know what im doing wrong?

 

Thanks

 

DigitalGuard

The first error is responsible for the others: it fails to open the "../imagehfw/hfw.jpg" file in

$im = ImageCreateFromjpeg("../imagehfw/hfw.jpg"); 

because it cannot find the file there (or has no permissions to access it if it does exist), so $im is false and this causes your other problems in the script.

 

The first error is responsible for the others: it fails to open the "../imagehfw/hfw.jpg" file in

$im = ImageCreateFromjpeg("../imagehfw/hfw.jpg"); 

because it cannot find the file there (or has no permissions to access it if it does exist), so $im is false and this causes your other problems in the script.

 

 

Well it does open becuase the image does load and the writting does get on it, so if its permissions or file doesn't exist how come the script does work?

 

 

Thanks

DigitalGuard

That file that outputs the image is probably being referenced from two pages having different paths. One reference works and outputs the image and one reference does not (perhaps you have some URL rewriting that is causing two requests) or the errors in the log are left over from before you got the correct path to hfw.jpg in the code.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.