PHP - can you upload an animated GIF?

Posted on 2009-04-20
Last Modified: 2012-05-06
I use the following code to upload images and would like to know if it can be modified to upload an animated gif.
Currently when I try to upload an animated gif the uploaded file beomes a static gif.
Thanks in advance for your feedback.
$image = imagecreatefromgif($tempFile);
//Get width & height of uploaded image.
$imWidth = imagesx($image);
$imHeight = imagesy($image);

if (($imWidth > $maxiw) || ($imHeight >  $maxih)){
$s = min($maxiw/$imWidth , $maxih/$imHeight);
$liWidth= round($s * $imWidth);
$liHeight= round($s * $imHeight);
}else {
$liWidth =  $imWidth;
$liHeight = $imHeight;

//Create Large Image
$largepic = imagecreatetruecolor($liWidth ,$liHeight);
imagecopyresampled($largepic, $image, 0, 0, 0, 0, $liWidth, $liHeight, $imWidth, $imHeight);
Question by:sabecs
    LVL 16

    Accepted Solution

    Apparently this is not as straight forward as it sounds. Gifs are still a proprietary format so support is patchy. However, this is something I have not tried.

    Author Closing Comment

    Thanks for your feedback.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now