Jump to content

Animated GIF


phpmash

Recommended Posts

I need to upload an animated/nonanimated GIF file in to my site.
And display it in another page.
So I want to know whether it is possible.
First I want to know whether the image is animated or not?
If it is not animated I want to add water mark
If so how can we display it in my second page.
I did it using our conventional GD method
BUt the animated effect lost
phpmash
Link to comment
Share on other sites

As far as I know, an animated gif looks the same as a non-animated one, file-wise. Can you add a little checkbox that says "Check here if animated" or something? Not sure what your purpose is, but I don't believe a section of code can figure out if a gif is animated or not.
Link to comment
Share on other sites

[!--quoteo(post=383008:date=Jun 12 2006, 10:58 PM:name=WendyLady)--][div class=\'quotetop\']QUOTE(WendyLady @ Jun 12 2006, 10:58 PM) [snapback]383008[/snapback][/div][div class=\'quotemain\'][!--quotec--]
As far as I know, an animated gif looks the same as a non-animated one, file-wise. Can you add a little checkbox that says "Check here if animated" or something? Not sure what your purpose is, but I don't believe a section of code can figure out if a gif is animated or not.
[/quote]

when a user uploads a animated file make sure the file has a swf exstention then do a check
aginst the exstention of swf with regular exspesion.
Link to comment
Share on other sites

ZeBadger from the php.net comments pages wrote the following function to check if a gif is animated or not. I have not tested it, but from looking at the code it is to be executed on a *NIX based machine, although it could be adapted to work with a Windows one, or even make it OS independant.

[code]<?php
function is_ani($filename){
    $filecontents=file_get_contents($filename);
    $str_loc=0;
    $count=0;
    while ($count < 2) { # There is no point in continuing after we find a 2nd frame
        $where1=strpos($filecontents,"\x00\x21\xF9\x04",$str_loc);
        if ($where1 === FALSE) {
            break;
        } else {
            $str_loc=$where1+1;
            $where2=strpos($filecontents,"\x00\x2C",$str_loc);
            if ($where2 === FALSE) {
                break;
            } else {
                if ($where1+8 == $where2) {
                    $count++;
                }
                $str_loc=$where2+1;
            }
        }
    }
    if ($count > 1) {
        return(true);
    } else {
        return(false);
    }
}

exec("ls *gif" ,$allfiles)
foreach ($allfiles as $thisfile) {
    if (is_ani($thisfile)) {
        echo "$thisfile is animated<BR>\n";
    } else {
        echo "$thisfile is NOT animated<BR>\n";
    }
}
?>[/code]
I dropped the semi-colon from the exec() line as it was causing issues posting.
Link to comment
Share on other sites

[!--quoteo(post=383116:date=Jun 13 2006, 01:19 AM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Jun 13 2006, 01:19 AM) [snapback]383116[/snapback][/div][div class=\'quotemain\'][!--quotec--]
when a user uploads a animated file make sure the file has a swf exstention then do a check
aginst the exstention of swf with regular exspesion.
[/quote]
dude... .swf is a flash file extension, not a gif file. a gif file is just that - blah.gif.
Link to comment
Share on other sites

[!--quoteo(post=383259:date=Jun 13 2006, 02:36 PM:name=Mash)--][div class=\'quotetop\']QUOTE(Mash @ Jun 13 2006, 02:36 PM) [snapback]383259[/snapback][/div][div class=\'quotemain\'][!--quotec--]
How can I create a thumbnail for animated image with animated effect?
[/quote]
This is possible with [a href=\"http://www.imagemagick.org\" target=\"_blank\"]ImageMagick[/a] I believe.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.