Jump to content


Photo

Animated GIF


  • Please log in to reply
8 replies to this topic

#1 phpmash

phpmash
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 12 June 2006 - 04:02 PM

Can anyone help me with a code to dispaly an animated GIF image using PHP
Thanking You
mash

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 12 June 2006 - 04:11 PM

umm..

<img src='blah.gif'>

?
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 phpmash

phpmash
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 12 June 2006 - 07:01 PM

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

#4 WendyLady

WendyLady
  • Members
  • PipPipPip
  • Advanced Member
  • 38 posts

Posted 12 June 2006 - 10:58 PM

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.


#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 June 2006 - 06:19 AM

[!--quoteo(post=383008:date=Jun 12 2006, 10:58 PM:name=WendyLady)--][div class=\'quotetop\']QUOTE(WendyLady @ Jun 12 2006, 10:58 PM) View Post[/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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 13 June 2006 - 12:38 PM

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.

<?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";
    }
}
?>
I dropped the semi-colon from the exec() line as it was causing issues posting.

#7 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 13 June 2006 - 01:11 PM

[!--quoteo(post=383116:date=Jun 13 2006, 01:19 AM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Jun 13 2006, 01:19 AM) View Post[/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.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#8 phpmash

phpmash
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 13 June 2006 - 01:36 PM

How can I create a thumbnail for animated image with animated effect?

#9 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 13 June 2006 - 09:10 PM

[!--quoteo(post=383259:date=Jun 13 2006, 02:36 PM:name=Mash)--][div class=\'quotetop\']QUOTE(Mash @ Jun 13 2006, 02:36 PM) View Post[/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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users