NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP GD problems

Jeff Knight jeff.knight at gmail.com
Wed Jul 12 16:56:03 EDT 2006


Try sending the headers at the last possible moment, i.e. just before
imagepng() so that if you do generate an error, it will display on the
page, and get rid of that @, you want to know if it is failing.

On 7/12/06, Andrew Kamm <kamm at andrewkamm.com> wrote:
> 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
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
> New York PHP Conference and Expo 2006
> http://www.nyphpcon.com
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
>
>



More information about the talk mailing list