Jump to content

Creating an image. Receiving "The image cannot be displayed...contains errors"


sabinmash

Recommended Posts

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.