Fatal Error when reaching: imagecreatetruecolor()

images php coding issues or problems here.

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Sat Oct 02, 2010 3:27 pm

Fatal Error when reaching: imagecreatetruecolor()

Postby Novice999 » Sat Oct 02, 2010 3:57 pm

The image creating part within the Captcha coding on our website is failing to work and I've been task to rectify (as well as update site). Fatal error occurs at: imagecreatetruecolor()

Using Dreamweaver and having configured my Windows XP laptop to act as a testing server, I've installed PHP. Running: <?php echo phpinfo(); ?> works successfully.

Running the following code to test my system (and the probable issue with the hosting company) results in:

// prints e.g. 'Current PHP version: 4.1.1'
echo 'Current PHP version: ' . phpversion();

// prints e.g. '2.0' or nothing if the extension isn't enabled
echo phpversion('tidy');

header ('Content-type: image/png');
$im = @imagecreatetruecolor(120, 20)
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);


"Current PHP version: 5.1.4
Warning: Cannot modify header information - headers already sent by (output started at c:\Inetpub\wwwroot\test\phpinfo.php:3) in c:\Inetpub\wwwroot\test\phpinfo.php on line 8"

Line 8 = header ('Content-type: image/png');

From research, I believe my Current PHP version: 5.1.4 contains a variant of GD 2.x but how can I confirm the GD Version on my Windows machine? Or what PHP code can I run to confirm? Otherwise, please can you suggest why imagecreatetruecolor() fails to run on my laptop, a windows7 laptop also configured to run PHP or our site on the hosting web server?

User avatar
php-forum Active User
php-forum Active User
Posts: 277
Joined: Wed Aug 25, 2010 10:42 am

Re: Fatal Error when reaching: imagecreatetruecolor()

Postby macek » Sun Oct 03, 2010 9:41 am

You cannot echo something and then send HEADER! ,.. delete ECHOs!

Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 2 guests