PHP GD problem

Status
Not open for further replies.

Mike

New member
Jun 27, 2006
6,777
116
0
51
On the firing line
Not really a problem with PHP's GD library, more of a problem with the "programmer" (me).

Here's the situation: I want to create an image using php gd once and save it so that it doesn't have to recreate it every time the page is loaded. So, here's the script:

Code:
<?php
include ('config.php');

if($img = @GetimageSize("images/logo.gif"))
    {
        // nothing
    }
        else
    {

        $text                = $site;
        $file                = "images/company_name.gif";
        $dim                = getimagesize($file);
        $imagewidth            = $dim[0];
        $imageheight        = $dim[1];
        $image                = imagecreatefromgif($file);
        $white                 = imagecolorallocate($image, 255, 255, 255);
        $font                 = "Spyroclassic.ttf";

        imageTTFtext($image, 16, 0, 6, 21, $white, $font, $text);
        imagegif($image,'images/logo.gif');
        header("Content-type: image/gif");
        imagedestroy($image);

    }

header( 'Location: [URL="http://www.my-domain.tld/test-directory/%E2%80%9D"]http://www.My-Domain.tld/test-directory/[/URL]index2.php' ) ;

?>
So, what happens is it checks to see if the file exists, and if it doesn't it creates the image and saves it - this works. If the file already exists, it redirects to the index2.php (the home page) and that works.

Here's where things fuck up, when it creates the image it won't redirect, it just gives me this error:

The image “http://www.My-Domain.tld/test-directory/” cannot be displayed, because it contains errors.
Anybody that can help me? Please?
 


It looks like the imagegif() call might be failing. Is that saving the image OK or is it not getting past that line?

Also: try adding

error_reporting (E_STRICT | E_ALL | E_ERROR | E_WARNING | E_PARSE );

to the top and see if PHP dumps out any more errors that will give us a clue.
 
Status
Not open for further replies.