PHP image upload problem
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/718491/resize-animated-gif-file-without-destroying-animation">Resize animated gif file without destroying animation</a>  </p>
</blockquote>



<p>When I upload animated images my animated images are not animated anymore when they are re-sized. Is there a way I can fix this? If so how? Can some one give me a detailed 
step by step explanation on how to do this?</p>

<p>Here is my PHP script.</p>

<pre><code>if (file_exists("../members/" . $_SESSION['user_id'] . "/images/" . $_FILES["avatar"]["name"])) {
    $thumb != $_FILES["avatar"]["name"];
} else if($_FILES["avatar"]["name"] == TRUE) {
  move_uploaded_file($_FILES["avatar"]["tmp_name"],
  "../members/" . $_SESSION['user_id'] . "/images/" . basename($_FILES["avatar"]["name"]));
  $thumb = basename($_FILES["avatar"]["name"]);
}

if($thumb == TRUE) {
    $save = "../members/" . $_SESSION['user_id'] . "/images/thumbs/" . basename($_FILES["avatar"]["name"]);
    $file = "../members/" . $_SESSION['user_id'] . "/images/" . basename($_FILES["avatar"]["name"]);

    list($width, $height, $type) = getimagesize($file);

    if ($width &gt;= 180){
        $modwidth = 180;
        $modheight = ((180.0/$width) * $height);
    } else {
        $modwidth = $width;
        $modheight = $height;
    }

    $tn = imagecreatetruecolor($modwidth, $modheight);
    if($type == 1) {
        $image = imagecreatefromgif($file);
    }

    if($type == 2) {
        $image = imagecreatefromjpeg($file);
    }

    if($type == 3) {
        $image = imagecreatefrompng($file);
    }
    imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);

    if($type == 1) {
        imagegif($tn, $save);
    }

    if($type == 2) {
        imagejpeg($tn, $save, 100);
    }

    if($type == 3) {
        imagepng($tn, $save, 9);
    }
}
</code></pre>
