sabinmash Posted December 21, 2011 Share Posted December 21, 2011 Been just trying to test out some basic code that utilizes gd. In Chrome i receive a blank page. In firefox I get "The image "image.php" cannot be displayed because it contains errors". There is no whitespace before or after the php tags, which seems to cause this error sometimes. $image = imagecreate(200,20); $background = imagecolorallocate($image, 0, 0, 0); $foreground = imagecolorallocate($image,255,255,255); imagestring($image, 5, 5, 1, "Test", $foreground); header("Content-type: image/jpeg"); $imagejpeg($image); I am just following a tutorial, and at this point in the tutorial i should get at least some garbled text, if not an image. I looked at other common causes. gd2 is un-commented in php.ini. phpinfo shows: GD Support enabled GD Version bundled (2.0.34 compatible) FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.4.3 GIF Read Support enabled GIF Create Support enabled JPEG Support enabled libJPEG Version 6b PNG Support enabled libPNG Version 1.2.46 WBMP Support enabled XBM Support enabled gd.jpeg_ignore_warning 0 0 I have not found any other solutions to try, or maybe I have made an error is checking these solutions. Any advice with be great! Thank you for your time. Quote Link to comment https://forums.phpfreaks.com/topic/253622-creating-an-image-receiving-the-image-cannot-be-displayedcontains-errors/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 21, 2011 Share Posted December 21, 2011 Comment out the header(.....); statement and browse to the URL of the file containing that code and see what you get in the browser. Quote Link to comment https://forums.phpfreaks.com/topic/253622-creating-an-image-receiving-the-image-cannot-be-displayedcontains-errors/#findComment-1300188 Share on other sites More sharing options...
mikosiko Posted December 21, 2011 Share Posted December 21, 2011 this line: $imagejpeg($image); should be: imagejpeg($image); Quote Link to comment https://forums.phpfreaks.com/topic/253622-creating-an-image-receiving-the-image-cannot-be-displayedcontains-errors/#findComment-1300191 Share on other sites More sharing options...
sabinmash Posted December 21, 2011 Author Share Posted December 21, 2011 Gaahh... the original line and your correction looked so similar i had to look 5 times before I caught it. Works now. Thank you so much! Quote Link to comment https://forums.phpfreaks.com/topic/253622-creating-an-image-receiving-the-image-cannot-be-displayedcontains-errors/#findComment-1300193 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.