开发者

Freezing GIF images

I have many animated .gifs on a page. I need a s开发者_开发技巧cript or code that can freeze the animation of these .gifs so they do not animate and freeze on the first frame.

Currently the backgrounds are table cell backgrounds like this:

<td background="animated_background_1.gif">

and

<td style="background-image:url('animated_background_2.gif');"> 


The HTML used to display image (or as a background image or whatever):

<img src="giftopng.php?image=mypic.gif" alt="" />

The test script called: "giftopng.php"

<?php

//Get image name from URL
$image=$_GET['image'];

//Load the image
$img = ImageCreateFromGif($image);

//Convert to PNG and send it to browser
if($img) {
header("Content-Type: image/png");
ImagePNG($img);

//Clean-up memory
ImageDestroy($img);
}
?>

You could use something like this (source http://php.net/manual/en/function.imagecreatefromgif.php).

If the load is too high then you could cache the static image.


Have a look at http://slbkbs.org/jsgif code, it could help you with this issue.

jsgif is an animated GIF player bookmarklet with support for pausing, going frame-by-frame, playing in reverse, and other features that one might expect from a video player.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜