Page 1 of 1

Trouble rendering GD image creation

Posted: Sat Sep 19, 2009 4:28 am
by black_hat
I have the latest version of WAMP installed with the following enabled in php.ini

extension=php_gd2.dll

gd.jpeg_ignore_warning = 0

but when I test

Code: Select all

 
header("Content-type: image/png");
$im = @imagecreate(110, 20)
    or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  "A Simple Text String", $text_color);
imagepng($im);
imagedestroy($im);
 
I get

Code: Select all

?PNG  ??? IHDR???n??????V,????PLTE????[an????fIDAT?c`?`fx???`?????41???????q?@?;{á0? ?i
Any ideas or further changes to the ini? Thanks

Re: Trouble rendering GD image creation

Posted: Sat Sep 19, 2009 8:07 am
by jackpf
what do you get if you comment out the "header('Content-Type...." line?

Any errors or anything? If not, try putting:

Code: Select all

ini_set('display_errors', E_ALL);
error_reporting(E_ALL);
at the top of the script.

It looks like the browser is trying to display the binary..

Re: Trouble rendering GD image creation

Posted: Sat Sep 19, 2009 12:20 pm
by Ollie Saunders
This is probably a headers already sent error. Only you're not seeing the errors because they are disabled. If you do what jackpf suggests you should see a header already sent error. Google will tell you how to fix those quite effortlessly.

Re: Trouble rendering GD image creation

Posted: Mon Sep 21, 2009 3:20 pm
by black_hat
Well I tried error logging with no result. I've since moved over to the Google graphing API and works for my requirements. As always, thank you for your prompt replies and insightful posts. Cheers,