title: imagecreatefrompng not working
body: <p>I am trying to create thumbnails of images, but I found that only JPG images can be converted into thumbnails by using the code below; it doesn't work with PNG and GIF. What am I doing wrong?</p>
  
  <pre><code>function createThumbs( $pathToImages,$pathToThumbs,$thumbWidth,$fname)
      {
        // open the directory
       // $dir = opendir( $pathToImages );
  
  
          // parse path for the extension
          $info = pathinfo($pathToImages);
  
          // continue only if this is a JPEG image
          //if ( strtolower($info['extension']) == 'jpg' )
          //{
            //echo "Creating thumbnail for {$fname} &lt;br /&gt;";
  
              echo strtolower($info['extension']);
              switch(strtolower($info['extension'])){
                  case 'jpg':
                          $img = imagecreatefromjpeg("{$pathToImages}" );
                      break;
                  case 'gif':
                          $img = imagecreatefromgif("{$pathToImages}" );
                      break;
                  case 'png':
                          $img = imagecreatefrompng("{$pathToImages}" );
                      break;
                  default:
                          die("ERROR: FILE TYPE DOES NOT SUPPORT");
                      break;
              }
            // load image and get image size
  
            $width = imagesx( $img );
            $height = imagesy( $img );
  
            // calculate thumbnail size
            $new_width = $thumbWidth;
            $new_height = floor( $height * ( $thumbWidth / $width ) );
  
            // create a new temporary image
            $tmp_img = imagecreatetruecolor( $new_width, $new_height );
  
            // copy and resize old image into new image
            imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
  
            // save thumbnail into a file
            imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" );
            chmod("{$pathToThumbs}{$fname}",777);
  
  
      }
  }
  </code></pre>