DigitalGuard Posted August 7, 2009 Share Posted August 7, 2009 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 Link to comment https://forums.phpfreaks.com/topic/169229-hello-with-this-script-i-get-error-log-errors/ Share on other sites More sharing options...
Mark Baker Posted August 7, 2009 Share Posted August 7, 2009 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. Link to comment https://forums.phpfreaks.com/topic/169229-hello-with-this-script-i-get-error-log-errors/#findComment-892957 Share on other sites More sharing options...
DigitalGuard Posted August 7, 2009 Author Share Posted August 7, 2009 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 Link to comment https://forums.phpfreaks.com/topic/169229-hello-with-this-script-i-get-error-log-errors/#findComment-893078 Share on other sites More sharing options...
Mark Baker Posted August 7, 2009 Share Posted August 7, 2009 Does it actually load, or are you just seeing a previously cached image? If those warnings are being written to the log, I can't understand how you could be seeing the image that the script generates. Link to comment https://forums.phpfreaks.com/topic/169229-hello-with-this-script-i-get-error-log-errors/#findComment-893092 Share on other sites More sharing options...
PFMaBiSmAd Posted August 7, 2009 Share Posted August 7, 2009 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. Link to comment https://forums.phpfreaks.com/topic/169229-hello-with-this-script-i-get-error-log-errors/#findComment-893098 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.