可能重複:
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