Page 1 of 1

Image creation and header problems

Posted: Thu Sep 23, 2004 3:09 pm
by tjc1027
I have a php script on apache that automatically creates the buttons for my site on the fly. It uses gd2. I moved the site to a new server and now I am having serious problems getting the script to run. the script is:

Code: Select all

<?
        header("content-type: image/jpeg");

        if (isset($FontSize)==false) $FontSize=12;
        if (isset($Gamma)==false) $Gamma=100;
        if (isset($Text)==false) $Text="Default";
        
        //$FontFile='c:/Fonts/ARLRDBD.TTF';
        $FontFile="c:\WINNT\Fonts\erasmd.TTF";
        // >> Get the width and height of the Message
        $BoxSize = imagettfbbox($FontSize, 0, $FontFile, $Text);
        
        if (isset($ImageWidth)==false)       
              $ImageWidth = $BoxSize[2]+14;
              
        if (isset($ImageHeight)==false)
              $ImageHeight = -$BoxSize[5]*1.7;

          // >> Load in the button
          $Center = imagecreatefromjpeg("..imagesbuttonsCenterBtn.jpg");
          
          $CenterWidth  = imagesx($Center);
          $CenterHeight = imagesy($Center);

        // >> Create the image
        $Image        = imagecreate($ImageWidth, $ImageHeight);
          $bgc         = ImageColorAllocate ($Image, 255, 255, 255);
          $FontColor  = ImageColorAllocate ($Image, 0, 0, 0);                       
          
          $LeftColor   = ImageColorAllocate($Image, 163, 176, 202);
          $RightColor  = ImageColorAllocate($Image, 185, 191, 203);
          $TopColor    = ImageColorAllocate($Image, 128, 137, 156);
          $BottomColor = ImageColorAllocate($Image, 136, 143, 162);
          
          // >> Draw the button
          ImageFilledRectangle ($Image, 0, 0, $ImageHeight, $ImageWidth, $bgc);
          
          imagecopyresized($Image, $Center, 0, 0, 0, 0, $ImageWidth, $ImageHeight,
    $CenterWidth, $CenterHeight);
          
          ImageLine($Image, 0, 1, 0, $ImageHeight-1, $LeftColor);
          ImageLine($Image, $ImageWidth-1, 1, $ImageWidth-1, $ImageHeight-1, $RightColor);

          ImageLine($Image, 1, 0, $ImageWidth-2, 0, $TopColor);
          ImageLine($Image, 1, $ImageHeight-1, $ImageWidth-2, $ImageHeight-1, $BottomColor);

          
        imagettftext($Image, $FontSize, 0, 7, $ImageHeight-$ImageHeight*0.29, $FontColor,
    $FontFile, $Text);
            
        imagegammacorrect($Image, 100, $Gamma);    
        
        imagejpeg($Image);
    ?>
It is being called like this:
&lt;input type="image" src="/cgi-bin/Button.jpg?Text=Login" name="LoginBtn" border="0" alt="Login"&gt;

I have an entry in the httpd.conf file to make .jpg in this folder run with php:
AddType application/x-httpd-php .jpg

The problem I am having is the image doesn't show up and I keep getting messages in the Apache error.log saying:
[Thu Sep 23 13:49:38 2004] [error] [client (IP Removed)] Premature end of script headers: c:/program files/apache group/apache/htdocs/cgi-bin/button.jpg

If anybody has any idea what might be going on here I would appreciate it.
Justin