title: imagecopyresampled after rotating the image
body: <p>I am trying to copy image (to <code>$img</code>)  after rotating image (many images <code>$im</code>) but I get weird behavior. Once I un-comment the line <code>//$img =</code> I only get the rotated image on my final output. Can I rotate the inner <code>$im</code> and copy it to final image<code>$img</code>?</p>
  
  <pre><code>&lt;?php
  
  $height =  80;
  $width  = 300;
  
  $img = imagecreate($width, $height);
  $c = imagecolorallocate ($img ,  135, 135, 135);
  imagefill($img, 0, 0, imagecolorallocate($img, 255, 255, 255));
  
  for($i=0; $i&lt;=5; $i++){
  
      $im = imagecreatetruecolor(35, 35);
      $gry = imagecolorallocate($im, 135, 135, 135);
      $wht = imagecolorallocate($im, 255, 255, 255);
  
      $j = mt_rand(0, 1);
  
      $ch = mt_rand(0,1)?chr(rand(65, 90)):chr(rand(97, 122));
  
      if($j == 0){
          imagefill($im, 0, 0, $wht);
          imagefttext($im, 20, 0, 3, 21, $gry, 'AHGBold.ttf', $ch);
          //$img = imagerotate($im, mt_rand(0,10)-5, $wht);
      }else{
          imagefill($im, 0, 0, $gry);
          imagefttext($im, 20, 0, 3, 21, $wht, 'AHGBold.ttf', $ch);
          //$img = imagerotate($im, mt_rand(0,10)-5, $gry);
      }
      imagecopyresampled($img, $im, 5 + $i*42, $height/2 - 12, 0, 0, 40, 40, 25, 25);
  }
  header('Content-type: image/png');
  imagepng($img);
  </code></pre>