title: creating png files
body: <p>I made a function to handle jpg and png files, but i get error when trying to upload a png file.</p>
  
  <p>this is the function:</p>
  
  <pre><code>function createImg ($type, $src, $dst, $width, $height, $quality) {
  
  $newImage = imagecreatetruecolor($width,$height);
  if ($type == "jpg/jpeg") {  
      //imagecreatefromjpeg() returns an image identifier representing the image obtained from the given filename.
      $source = imagecreatefromjpeg($src);
  }
  else if ($type == "png") {
      //imagecreatefrompng() returns an image identifier representing the image obtained from the given filename.
      $source = imagecreatefrompng($src);
  }
  imagecopyresampled($newImage,$source,0,0,0,0,$width,$height,getWidth($src),getHeight($src));
  if ($type == "jpg/jpeg") {
      //imagejpeg() creates a JPEG file from the given image. 
      imagejpeg($newImage,$dst,$quality); 
  }
  else if ($type == "png") {
      //imagepng() creates a PNG file from the given image. 
      imagepng($newImage,$dst,$quality);      
  }
  return $dst;
  </code></pre>
  
  <p>}</p>
  
  <p>works as it should with jpg, but with png i get this error msg:</p>
  
  <p>Warning: imagepng() [function.imagepng]: gd-png: fatal libpng error: zlib failed to initialize compressor -- stream error in E:...\php\functions.upload.php on line 48</p>
  
  <p>Warning: imagepng() [function.imagepng]: gd-png error: setjmp returns error condition in E:...\php\functions.upload.php on line 48</p>
  
  <p>EDIT : </p>
  
  <p>i just changed removed the imagepng(); and used only imagejpeg and it worked like this, i just want jpg files saved anyways. thanks!</p>