title: What is imagecreatetruecolor used for?
body: <p>According to</p>
  
  <p><a href="http://php.net/manual/en/function.imagecreatetruecolor.php" rel="nofollow">http://php.net/manual/en/function.imagecreatetruecolor.php</a></p>
  
  <blockquote>
    <p>it creates a new true color image</p>
  </blockquote>
  
  <p>but just further down is states:</p>
  
  <blockquote>
    <p>... returns an image identifier representing a
    black image of the specified size.</p>
  </blockquote>
  
  <p>This is in some boiler plate code I use for image uploads ( to create a JPEG ) as follows:</p>
  
  <pre><code>private function createFinalJPEG($max, $path)
  {
      $this-&gt;makeDimensions($max);
      $this-&gt;image_y = imagecreatetruecolor($this-&gt;new_width, $this-&gt;new_height);
      imagecopyresampled($this-&gt;image_y, $this-&gt;image_z, 0, 0, 0, 0, 
              $this-&gt;new_width, $this-&gt;new_height,
              $this-&gt;original_width, $this-&gt;original_height);
      imagejpeg($this-&gt;image_y, $path);
      imagedestroy($this-&gt;image_y);
  }
  </code></pre>
  
  <p>In general do I need so many intermediary image representations to produce the end file?</p>
  
  <p>Is imagecreatetruecolor simply creating a dumb black image to be used as place holder that imagecopyresampled can use?</p>
  
  <p>In response an answer here is how image_z is created:</p>
  
  <pre><code>private function createImageZ($path)
  {
      $type_creators = array(
          'image/gif' =&gt; 'imagecreatefromgif',
          'image/pjpeg' =&gt; 'imagecreatefromjpeg',
          'image/jpeg' =&gt; 'imagecreatefromjpeg',
          'image/png' =&gt; 'imagecreatefrompng');
      if(array_key_exists($this-&gt;fileType, $type_creators))
      {
          $this-&gt;image_z = $type_creators[$this-&gt;fileType]($path);
          return true;
      }
      return false;
  }
  </code></pre>