title: Imagecreate/GD issues(PHP)
body: <p>I'm using the following function that I slightly tweaked from the php site a user posted.</p>
  
  <pre><code>function createImgText ($string=NULL, $fontsize=0, $marginX=0, $imgH=0, $fontfile=NULL, $imgColorHex=NULL, $txtColorHex=NULL){
      if($string != ""){
      //header("Content-type: image/png");    
      //
      $spacing = 0;
  
      $line = array("linespacing" =&gt; $spacing);
  
      if (file_exists($fontfile)) $box = @imageftbbox($fontsize,0,$fontfile,$string,$line) or die('Box command error');
      else die("ERROR - font");
  
      $tw=$box[4]-$box[0]; //image width
      $marginY = $imgH - (($imgH - $fontsize) / 2);
      $imgWidth = $tw + (2*$marginX);
      $im = ImageCreate($imgWidth, $imgH);
      $int = hexdec($imgColorHex);
      $arr = array("red" =&gt; 0xFF &amp; ($int &gt;&gt; 0x10),
             "green" =&gt; 0xFF &amp; ($int &gt;&gt; 0x8),
             "blue" =&gt; 0xFF &amp; $int);
      $black = ImageColorAllocate($im, $arr["red"], $arr["green"], $arr["blue"]);
      $int = hexdec($txtColorHex);
      $arr = array("red" =&gt; 0xFF &amp; ($int &gt;&gt; 0x10),
             "green" =&gt; 0xFF &amp; ($int &gt;&gt; 0x8),
             "blue" =&gt; 0xFF &amp; $int);
      $white = ImageColorAllocate($im, $arr["red"], $arr["green"], $arr["blue"]);
      ImageFtText($im, $fontsize, 0, $marginX, $marginY, $white, $fontfile, $string, array());
      ImagePng($im);
      ImageDestroy($im);
  }else{
      echo "ERROR - no string";
  }
  }
  </code></pre>
  
  <p>I'm using the following in my index.php</p>
  
  <pre><code>  error_reporting(-1); 
    ini_set('display_errors', true);
  </code></pre>
  
  <p>and the page that outputs the image.</p>
  
  <p>I'm not receiving any errors. :( 
  However, uncommenting the header portion causes Firefox to say "The image contains errors and will not be displayed".</p>
  
  <p>Image php file:</p>
  
  <pre><code>&lt;?php
   error_reporting(-1); 
  ini_set('display_errors', true);
  $code = $sys-&gt;core-&gt;generateRandomString($sys-&gt;settings['captchal']);
  echo 'Debug: Using string: ' . $code . ' font: fonts/' . $sys-&gt;settings['captchaf'] . '&lt;br&gt;';
  
  
  $sys-&gt;core-&gt;createImgText($code, 9, 10, 18, 'fonts/' . $sys-&gt;settings['captchaf'], "000000", "FFFFFF");
  ?&gt; 
  </code></pre>
  
  <p>It says:</p>
  
  <pre><code>Debug: Using string: nrcujP font: fonts/airstream.ttf
  �PNG  IHDR0�H@�PLTE������������???___uV#�pIDAT�c` �E�D�x���*�s�bP     �@fR�SVV``�F�0t4UTu6uuh3rl@�+4h3k6 �),6F�!�P�LHPTD8� �c�p�,�8�( �8�Q+|�Q��IEND�B`� 
  </code></pre>
  
  <p>I have a page with </p>
  
  <pre><code> &lt;?php echo phpinfo(); ?&gt; 
  </code></pre>
  
  <p>it says GD is enabled and all addons, including TTF support. Anyone ever have a similar problem before? I've tried other things, and it seems to fail on the second ImageColorAllocate. I don't see any mention of it on google when I search. It's suppose to render an image when called then destroy itself, not take up file space.</p>
  
  <hr>
  
  <p>Problem solved with the help of NXT. I had a whitespace before </p>
  
  <pre><code> &lt;?php 
  </code></pre>
  
  <p>that I had overlooked.</p>