可能重复:
PHP - Create simple animated GIF from two JPEG images?如何创建动画图像?
我有一个简单的JPG图片。我想创建一个动画图像。
任何人都可以建议我的任何想法。
我对imagegif想法()。但那不是我需要的。我想创建一个从简单的jpg图像移动的图像。可能吗。
任何帮助是非常可观的。
感谢名单
可能重复:
PHP - Create simple animated GIF from two JPEG images?如何创建动画图像?
我有一个简单的JPG图片。我想创建一个动画图像。
任何人都可以建议我的任何想法。
我对imagegif想法()。但那不是我需要的。我想创建一个从简单的jpg图像移动的图像。可能吗。
任何帮助是非常可观的。
感谢名单
我试过了,但结果的图像大小比我需要的大。我有两个需要动画的png文件。该PNG图像的大小是80x84px,但结果是84x88。我怎样才能得到我的PNG文件的图像大小。 – Batuli 2010-12-03 05:09:10
您可以使用gifmerge类的易
在你的CSS文件中使用此代码
-webkit-动画名称:脉冲; -webkit-animation-duration:2s; -webkit-animation-iteration-count:infinite; -webkit-animation-timing-function:轻松进出; -webkit-animation-direction:alternate; }
和HTML
如果你的浏览器为Mozilla firedox与MOZ取代的WebKit。
乐趣..
这不是完全清楚你从问题中找什么,但如果你想要的是采取单一的形象,使之成为一个动画,你有几个选项:
最有趣的,从编程的角度来看这些选项#1(#2 - 是的,所有你需要的是像imagegif)。
您可以使用ImageMagick distortion effects通过PHP通过IMagick到ImageMagick的PHP接口。你想要的是在那里选择一个失真方法(有很多),然后用稍微变化的参数对着源图像多次运行它,以产生不同的帧。在此之后,您可以将生成的帧与imagegif()或类似的结合起来。
这不能用GD来完成,但我找到了一个很棒的库。这有点复杂,所以这里是一个链接到图书馆使用php制作GIF动画。它解释了如何彻底使用它。 http://www.phpclasses.org/package/3163-PHP-Generate-GIF-animations-from-a-set-of-GIF-images.html
你可以看一下我的例子在这里使用这个库:http://cmon.horizon-host.com/gifs/slideshow_normal.php 在现场只需选择两张照片,并为宽度和高度速度900写100。它会将它们放入动画GIF幻灯片中。
下面是该脚本代码:
<?php
if(isset($_POST['speed']))
{
header('Content-type: image/gif');
if(isset($_POST['download'])){
header('Content-Disposition: attachment; filename="animated.gif"');
}
include('GIFEncoder.class.php');
function frame($image){
ob_start();
imagegif($image);
global $frames, $framed;
$frames[]=ob_get_contents();
$framed[]=$_POST['speed'];
ob_end_clean();
}
foreach ($_FILES["images"]["error"] as $key => $error)
{
if ($error == UPLOAD_ERR_OK)
{
$tmp_name = $_FILES["images"]["tmp_name"][$key];
$im = imagecreatefromstring(file_get_contents($tmp_name));
$resized = imagecreatetruecolor($_POST['width'],$_POST['height']);
imagecopyresized($resized, $im, 0, 0, 0, 0, $_POST['width'], $_POST['height'], imagesx($im), imagesy($im));
frame($resized);
}
}
$gif = new GIFEncoder($frames,$framed,0,2,0,0,0,'bin');
echo $gif->GetAnimation();
}
?>
<form action="" method="post" enctype="multipart/form-data">
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="jquery.MultiFile.js"></script>
<script src="jquery.placeholder.js"></script>
<input type="file" name="images[]" class="multi" />
<script>
$(function(){
$('input[placeholder], textarea[placeholder]').placeholder();
});
</script>
<SCRIPT language=Javascript>
<!--
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
//-->
</SCRIPT>
<input name="speed" maxlength="10" type="text" placeholder="Speed of frames in ms" onkeypress="return isNumberKey(event)">
<input name="width" maxlength="4" type="text" placeholder="Width" onkeypress="return isNumberKey(event)">
<input name="height" maxlength="4" type="text" placeholder="Height" onkeypress="return isNumberKey(event)">
<input type="submit" name="download" value="Download!">
<input type="submit" name="preview" value="Preview!">
</form>
正如你看到它引用的第一个链接上发现的GIFEncoder类。它也使用一些JavaScript验证和jQuery multiupload。
注意:这个问题已经被问到。
请说明。动画是一系列图像。单张图片无法通过定义进行动画制作。 – 2010-12-03 04:26:04
你的意思是在页面周围移动一个静态图像或使静态图像的内容移动? – 2010-12-03 04:26:08
澄清我的retag:他提到imagegif(http://php.net/manual/en/function.imagegif.php),这就是为什么我添加了“php”标签。 – 2010-12-03 04:31:15