冻结GIF图像 [英] Freezing GIF images

查看:71
本文介绍了冻结GIF图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面上有很多动画的.gif文件.我需要一个可以冻结这些.gif动画的脚本或代码,以使它们不会在第一帧动画或冻结.

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 backgrounds are table cell backgrounds like this:

<td background="animated_background_1.gif">

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

推荐答案

用于显示图片(或作为背景图片或其他图片)的HTML:

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

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

测试脚本名为:"giftopng.php"

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);
}
?>

您可以使用类似的方法(来源 http://php.net/manual/zh/function.imagecreatefromgif.php ).

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.

这篇关于冻结GIF图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆