title: cakephp - debugger error using imagecreatefrompng()
body: <p>I have some code which breaks when I use imagecreatefrompng() in an action in my controller. I don't think it should make a difference but the imagecreatefrompng() is called inside an action which has been called via AJAX.</p>
  <pre><code>$imgName='img/favicons/'.$saveFileName.'_large.png';
  $img=imagecreatefrompng($imgName);
  </code></pre>
  <p>I'm pretty sure the path is right. In the same action I save a file to that very folder, however I get returned the following errors:</p>
  <blockquote>
  <p><b>Warning</b>:  get_class() expects parameter 1 to be object, resource given in <b>C:\xampp\htdocs\cakephp\lib\Cake\Utility\Debugger.php</b> on line <b>578</b></p>
  <p><b>Warning</b>:  get_object_vars() expects parameter 1 to be object, resource given in <b>C:\xampp\htdocs\cakephp\lib\Cake\Utility\Debugger.php</b> on line <b>584</b></p>
  </blockquote>
  <p>The particular function in the debugger.php file that the errors point to handles object to string conversion, and the lines which cause the error are:</p>
  <pre><code>$className = get_class($var);
  $objectVars = get_object_vars($var);
  </code></pre>
  <p>Anyone have any ideas what's going wrong? Thanks</p>
  <p><strong>EDIT :</strong></p>
  <p>Here's the code for the function</p>
  <pre><code>public function saveSiteFavicon() {
      $this-&gt;layout = 'ajax';
      $url = $this-&gt;request-&gt;data['websiteurl'];
      $saveFileName = parse_url($url);
      $saveFileName = $saveFileName['host'];
      $saveFileName = str_replace('.', '', $saveFileName);
      $saveFileName = str_replace('www', '', $saveFileName);
      $this-&gt;Favicon-&gt;recursive = 0;
      $faviconexists = $this-&gt;Favicon-&gt;findByImage($saveFileName.'.png');
      if(!empty($faviconexists)) {
          echo $saveFileName.'.png:'.$faviconexists['Favicon']['id'];
      } else {
          $fp = fopen ('img/favicons/'.$saveFileName.'.png', 'w+');
          $ch = curl_init('http://g.etfv.co/'.$url);
          curl_setopt($ch, CURLOPT_TIMEOUT, 6);
          /* Save the returned data to a file */
          curl_setopt($ch, CURLOPT_FILE, $fp);
          curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
          curl_exec($ch);
          curl_close($ch);
          fclose($fp);
          //if the favicon is oversized resize it
          $faviconFileName = 'img/favicons/'.$saveFileName.'.png';
          $metaData=getimagesize($faviconFileName);
          if($metaData[1] &gt; 16) {
              rename($faviconFileName, 'img/favicons/'.$saveFileName.'_large.png');
              $imgName='img/favicons/'.$saveFileName.'_large.png';
              $thumbName='img/favicons/'.$saveFileName.'.png';
              $img=imagecreatefrompng($imgName);
              
              $imgThumb=imagecreatetruecolor(16,16);
              imagecopyresampled($imgThumb,$img,0,0,0,0,16,16,$metaData[0],$metaData[1]);
              imagepng($imgThumb, $thumbName);
              imagedestroy($imgThumb);
          }
          $this-&gt;Favicon-&gt;create();
          $this-&gt;Favicon-&gt;save(array('image'=&gt;$saveFileName.'.png'));
          $faviconid = $this-&gt;Favicon-&gt;getLastInsertId();
          echo $saveFileName.'.png:'.$faviconid;
      }
  }
  </code></pre>
  <p>and in the view I just call this function via ajax and alert the results which is where I see the error messages.</p>
  <pre><code>$.post(&quot;../favicons/saveSiteFavicon&quot;, {websiteurl: value})
                  .done(function(data) {
                      alert(data);
              });
  </code></pre>