php GD output to file issue

GD and GD2 are useful libraries for creating graphics on-the-fly. Discuss your PHP GD and GD2 scripts here.

Moderators: onion2k, General Moderators

Post Reply
hotet
Forum Newbie
Posts: 1
Joined: Sat Apr 21, 2007 4:01 pm

php GD output to file issue

Post by hotet »

Greetings!
I have an issue with outputting a GD-script to a file on the server
My script:

Code: Select all

<?
  include_once("inc/ *******.php");
  header ("Content-type: image/jpeg");
  $result = mysql_query("SELECT * FROM ******WHERE zid = '".$_GET['zid']."'");
  $background = imagecreatefromgif("img/bakgrund.gif");
  	$i=0;
    while ($s = mysql_fetch_array($result, MYSQL_ASSOC))
    {
      if ((!($i%32)) && ($i))
	  {
	    $hojd++;
		$j=0;
	  }
	  $insert = imagecreatefromgif("img/map/". $s['img_url'].".gif");
	  imagecopymerge($background,$insert,($j*16),($hojd*16),0,0,16,16,100);
	  $j++;
      $i++;
    }
  $filnamn = $_GET['zid'].".jpg";
  imagejpeg($background, $filnamn, 100);
  imagedestroy($background);
  imagedestroy($insert);
?>
The script it self works like a charm so dont mind it. (It can output correctly without the optional $filnamn argument). The issue must be in this section:
It's supposed to generate an image named after the zid specified. For example "1.jpg", "2.jpg" and so on. One at a time ofc.

Code: Select all

imagejpeg($background, $filnamn,100);
I have tried various methods changing headers and CHMOD the file to 777. For the record the server is a UNIX-based system running Apache 1.3.37, PHP Version 4.4.4
Post Reply