title: ERROR while editing photo PHP FACEBOOK API
body: <p>What I am trying to do is:</p>
  
  <ul>
  <li>Get person profile pic;</li>
  <li>Get a randon pic that is set with de switch</li>
  <li>And mix the random pic with the person profile pic</li>
  <li>And show it to the guy!</li>
  </ul>
  
  <p>Can  do this?</p>
  
  <pre><code>require_once("src/facebook.php");
  
  $configurar = array();
  $configurar['appId'] = '2033xxxxx389';
  $configurar['secret'] = 'cc3xxxx9b1';
  $configurar['fileUpload'] = true;
  
  $facebook = new Facebook($configurar);
  
  $signed_request = $facebook-&gt;getSignedRequest();
  $__idPagina = $signed_request["page"]["id"];
  $__adminPagina = $signed_request["page"]["admin"];
  $__statusLike = $signed_request["page"]["liked"];
  $__pais = $signed_request["user"]["country"];
  $__locale = $signed_request["user"]["locale"];
  
  $_idUsuario = $facebook-&gt;getUser();
  ?&gt;
  &lt;html&gt;
      &lt;head&gt;&lt;/head&gt;
      &lt;body&gt;
  
          &lt;?
              if($_idUsuario)
              {
                  try
                  {
                      if($__statusLike)
                      {
                          //AQUI VAI A PARTE QUE FUNCIONA A MÁGICA DA FOTO! POORRA
                          // DEFINIR VARIAVEIS
                          $foto_x = $_idUsuario."_x.jpg";
                          $foto_y = $_idUsuario."_y.jpg";
                          $img = $_idUsuario.".jpg";
  
                          copy('http://graph.facebook.com/'.$_idUsuario.'/picture?width=150&amp;height=150', 'lixeira/'.$foto_x);
  
                          //ARMA ALEATÓRIA NA BAGAÇA
                          $armaRandomica = rand(1,10);
  
                          //DEFINE O MOLDE DE ACORDO COMO O NUMERO QUE PEGOU AI /\
  
                          switch ($armaRandomica) {
                              case 1:
                                  $moldeArma = "molde/_bazuka.jpg";
                                  break;
                              case 2:
                                  $moldeArma = "molde/_espada.jpg";
                                  break;
                              case 3:
                                  $moldeArma = "molde/_espingarda.jpg";
                                  break;
                              case 4:
                                  $moldeArma = "molde/_faca.jpg";
                                  break;
                              case 5:
                                  $moldeArma = "molde/_granada.jpg";
                                  break;
                              case 6:
                                  $moldeArma = "molde/_metralhadora.jpg";
                                  break;
                              case 7:
                                  $moldeArma = "molde/_nokia.jpg";
                                  break;
                              case 8:
                                  $moldeArma = "molde/_pistola.jpg";
                                  break;
                              case 9:
                                  $moldeArma = "molde/_shotgun.jpg";
                                  break;
                              case 10:
                                  $moldeArma = "molde/_sniper.jpg";
                                  break;
                              }
  
                          echo '&lt;img src="'.$moldeArma.'" /&gt;';
  
                          //JUNTAR A FOTO DO PERFIL COM O MOLDE!
  
                          header("Content-type:image/jpeg");
  
                          $stamp = imagecreatefromjpeg($foto_x);
                          $im = imagecreatefromjpeg($moldeArma);
                          $marge_right = 20;
                          $marge_bottom = 330;
                          $sx = imagesx($stamp);
                          $sy = imagesy($stamp);
                          imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));
                          imagejpeg($im, $foto_y,100);
                          imagedestroy($im);                      
                          exit;
  
                          //USA ISSO COMO $perfilUsuario['name'] e talz!
                          $perfilUsuario = $facebook-&gt;api('/me','GET');
  
                          //MOSTRA A FOTO PRO NEGRO!
                          echo '&lt;img src="lixeira/'.$foto_x.'" /&gt;';
                      }
                      else
                      {
                          echo '&lt;center&gt;&lt;img src="imagens/curta.png"/&gt;&lt;/center&gt;';
                      }
                  }
                  catch(FacebookApiException $e)
                  {
                      $urlLogin = $facebook-&gt;getLoginUrl();
                      echo 'Porfavor &lt;a href="'.$urlLogin.'"&gt;LOGUE!&lt;/a&gt;';
                      error_log($e-&gt;getType());
                      error_log($e-&gt;getMessage());
                  }
              }
              else
              {
                  $urlLogin = $facebook-&gt;getLoginUrl();
                  echo 'Porfavor &lt;a href="'.$urlLogin.'"&gt;LOGUE!&lt;/a&gt;';
              }
          ?&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And this is what I get from that code, what should I do to fix this error?</p>
  
  <p><a href="http://i.stack.imgur.com/lrFKd.png" rel="nofollow">http://i.stack.imgur.com/lrFKd.png</a></p>
  
  <p>Help me people =D</p>