PHP & Gif - Gif not animated now :(

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

PHP & Gif - Gif not animated now :(

Post by Dale »

Code: Select all

<?php
header("Content-type: image/gif");

$im = imagecreatefromgif("./bannerads/banner1.gif");

imagegif($im);

imagedestroy($im);
?>
I'm using this code above to show a GIF on a website, however that GIF is animated, howver when using the script above its not animated, is there a way to get around this?
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

...why not just show the gif with html instead of making a new gif out of a gif?
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Because i want the GIF's to be configured in a database, like what ones are shown on each page, and i cannot be bothered to rename every .HTM file to a .PHP, as i would also have to update every link on each page too.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

after a quick google search i came up with that it is best to use your gd library with imagequick which can make animated gifs but i think this would probebly be the most difficult way to go about doing this.

i am sure that there is a easier way to do this than the way you are doing it because already you are renaming the files to .php to show the new gif are you not? there has to be somthing i am missing becuase making a gif from a gif without changing anything seams like a very unnecciary way of doing things
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

shiznatix wrote:i am sure that there is a easier way to do this than the way you are doing it because already you are renaming the files to .php to show the new gif are you not?
Nah, im keeping them .HTM, and just using the image tag liek so:

Code: Select all

<img src="./banner.php?banner=1">
So then instead of changing the code on each page, i can just update it from 1 central control panel, also monitor how many clicks, ect..
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you can just supply the image file directly to the browser without futzing with image controls...

readfile()
Post Reply