NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP GD problems

Andrew Kamm kamm at andrewkamm.com
Wed Jul 12 16:45:08 EDT 2006


Hello all -- I'm having a problem with image creation with PHP and even
though it appears my bases are covered, I can't get it resolved. I ran
gd_info() and it appears to be alright for what I need (BTW, this is a Win
server w/ PHP5.1.4, but I've also tried it on a Linux box and got the same
results):

Array
(
    [GD Version] => bundled (2.0.28 compatible)
    [FreeType Support] => 1
    [FreeType Linkage] => with freetype
    [T1Lib Support] => 1
    [GIF Read Support] => 1
    [GIF Create Support] => 1
    [JPG Support] => 1
    [PNG Support] => 1
    [WBMP Support] => 1
    [XPM Support] =>
    [XBM Support] => 1
    [JIS-mapped Japanese Font Support] =>
)

I've tried several different code snippets and get the same result:

In Firefox:
"The image "http://example.com/scripts/test.php" cannot be displayed,
because it contains errors."

In Safari:
Nothing -- but if you right-click anywhere on the screen it gives the same
dialogue box you'd get if you right-clicked an image.

As an example of the code I've been trying, I used the one below (from
PHP.net). I've made sure there is no additional whitespace outside of the
php tags.

<?php
header("Content-type: image/png");
$im = @imagecreate(100, 50)
   or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  "A Simple Text String", $text_color);
imagepng($im);
imagedestroy($im);
?>

Any ideas? All the similar problem/solutions I've found on Google seem to
relate to people having whitespace before the <?php tag.

thanks!

-- 
Andrew Kamm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20060712/b9fd11bb/attachment.html>


More information about the talk mailing list