title: Create a transparent png file using PHP
body: <p>Currently I would like to create a transparent png with the lowest quality .</p>
  
  <p>The code:</p>
  
  <pre><code>&lt;?php
  function createImg ($src, $dst, $width, $height, $quality) {
      $newImage = imagecreatetruecolor($width,$height);
      $source = imagecreatefrompng($src); //imagecreatefrompng() returns an image identifier representing the image obtained from the given filename.
      imagecopyresampled($newImage,$source,0,0,0,0,$width,$height,$width,$height);
      imagepng($newImage,$dst,$quality);      //imagepng() creates a PNG file from the given image. 
      return $dst;
  }
  
  createImg ('test.png','test.png','1920','1080','1');
  ?&gt;
  </code></pre>
  
  <p>However, there are some problems:</p>
  
  <ol>
  <li><p>Do I need to specific a png file before creating any new file? Or can I create without any existing png file? </p>
  
  <p>Warning: imagecreatefrompng(test.png): failed to open stream: No such file or directory in </p>
  
  <p>C:\DSPadmin\DEV\ajax_optipng1.5\create.php on line 4</p></li>
  <li><p>Although there are error message , it still generate a png file , however, what I found that is the file is a black color image , do I need to specific any parameter to make it transparent? </p></li>
  </ol>
  
  <p>Thanks.</p>