Skip to content Skip to sidebar Skip to footer

Freezing GIF Images

I have many animated .gifs on a page. I need a script or code that can freeze the animation of these .gifs so they do not animate and freeze on the first frame. Currently the backg

Solution 1:

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.


Solution 2:

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.


Post a Comment for "Freezing GIF Images"