title: Keep gif animation
body: <p>I'm using the following script to generate animated GIFs: <a href="http://www.jeroenvanwissen.nl/weblog/php/howto-generate-animated-gif-with-php" rel="nofollow">http://www.jeroenvanwissen.nl/weblog/php/howto-generate-animated-gif-with-php</a></p>
  
  <pre><code>if (!getimagesize($_FILES['myfile']['tmp_name']))
  {
      array_push($errors, 'Invalid image file');
  }
  else
  {
      $uploaded_type = exif_imagetype($_FILES["myfile"]["tmp_name"]); 
  
      switch($uploaded_type) 
      {
          case '1':
              $uploaded_type = 'gif';
  
              if(is_ani($_FILES['myfile']['tmp_name']))
                  $is_animated = true;
  
              $image = imagecreatefromgif($_FILES['myfile']['tmp_name']);
  
  
          break;
          case '2':
              $uploaded_type = 'jpg';
              $image = imagecreatefromjpeg($_FILES['myfile']['tmp_name']);
          break;
          case '3':
              $uploaded_type = 'png';
              $image = imagecreatefrompng($_FILES['myfile']['tmp_name']);
          break;
      }
  
      list($width, $height, $type, $attr) = getimagesize($_FILES['myfile']['tmp_name']);
      $originalWidth = $width;
      $originalHeight = $height;
  }
  
  $new_image = imagecreatetruecolor($newWidth, $newHeight);
  
  imagecopyresampled($new_image, $image, 0, 0, 0, 0, $newWidth, $newHeight, $originalWidth, $originalHeight); 
  
  ob_start();
  imagegif($new_image);
  $frames[]=ob_get_contents();
  $framed[]=40; 
  ob_end_clean();
  
  ob_start();
  imagegif($new_image);
  $frames[]=ob_get_contents();
  $framed[]=40; 
  ob_end_clean();
  
  $gif = new GIFEncoder($frames,$framed,0,2,0,0,0,'bin');
  
  $fp = fopen($baseUrl . $filename, 'w');
  fwrite($fp, $gif-&gt;GetAnimation());
  fclose($fp);
  </code></pre>
  
  <p>Is there any way to keep a gif animation, if it already exists? My check for animated gifs seem to work, but i cant manage to maintain it. Any help is much appreciated.</p>