如何创建动画图像?

发布于 2024-10-05 23:21:21 字数 427 浏览 5 评论 0原文

可能的重复:
PHP - 从两个 JPEG 图像创建简单的动画 GIF?

我有一个简单的 jpg 图像,我想用它创建动画图像。

有人能给我建议吗?

我对 imagegif() 有想法。但这不是我需要的。我想创建一个从简单的 jpg 图像移动的图像。是否可以。

我考虑过 imagegif(),但这不是我需要的。如果可能的话,我想从 JPG 图像创建移动图像。

任何帮助将不胜感激。

谢谢。

Possible Duplicate:
PHP - Create simple animated GIF from two JPEG images?

I have a simple jpg image, and I want to create animated image with it.

Can anyone suggest me any ideas?

i have idea about imagegif(). But that is not what i need. I want to create a image that moves from that simple jpg image. Is it possible.

I've thought about imagegif(), but that was not what I needed. I want to create a moving image from JPG image, if it's possible.

Any help will be highly appreciated.

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

风情万种。 2024-10-12 23:21:21

只需浏览此网站并上传 2,3,4.5 张任意数量的图片即可进行排序。

尝试一下

picasion.com

Wasim

Just go through this website and upload 2,3,4.5 as many pictures you like for sequencing.

Try it

picasion.com

with regards,

Wasim

焚却相思 2024-10-12 23:21:21

您可以使用 gifmerge 类,它很简单

试试我!

You can use gifmerge class its easy

Try me !

感性不性感 2024-10-12 23:21:21

目前尚不完全清楚您要从问题中寻找什么,但如果您想要拍摄一张图像并将其制作为动画图像,您有几个选择:

  1. 以某种算法方式将其动画化(例如“波浪”效果或“水下”效果)
  2. 基于它手动创建多个帧,每个帧之间有细微的变化(在 PHotoshop、GIMP 等中)

从编程的角度来看,这些选项中最有趣的是#1(对于#2 -是的,您所需要的只是 imagegif 之类的东西)。

您可以通过 PHP 通过 IMagick ImageMagick 的 PHP 接口。您想要的是在那里选择一种失真方法(有很多),然后使用稍微不同的参数对源图像运行几次,以产生不同的帧。之后,您可以将生成的帧与 imagegif() 或类似的函数组合起来。

It's not totally clear what you're looking for from the question, but if what you want is to take a single image and make it an animated one, you have a couple of options:

  1. Animate it in some algorithmic way (for example a "wave" effect or "underwater" effect)
  2. Manually create multiple frames based on it with subtle variation from one to the next (in PHotoshop, GIMP, etc)

The most interesting of these options from a programming standpoint is #1 (for #2 - yes, all you'd need is something like imagegif).

You could use ImageMagick distortion effects via PHP via the IMagick PHP interface to ImageMagick. What you'd want is to pick a distortion method there (there are plenty), then run it against the source image several times with slightly varied parameters, to produce different frames. After this, you can combine the resulting frames with imagegif() or similar.

明明#如月 2024-10-12 23:21:21

这不能用 GD 来完成,但我找到了一个很棒的库。虽然它有点复杂,所以这里有一个使用 php 制作动画 gif 的库的链接。它解释了如何彻底使用它。 http:// /www.phpclasses.org/package/3163-PHP-Generate-GIF-animations-from-a-set-of-GIF-images.html

您可以在此处查看我使用此库的示例:http://cmon.horizo​​n-host.com/gifs/slideshow_normal.php
在网站上只需选择 2 张图片,然后在宽度和高度上写上 100 表示速度 900。它将把它们放入动画 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 多重上传。

注意:这个问题已经被问过。

This cannot be done with GD but I found a great library for it. It is a bit complicated though, so here is a link to the library which makes animated gifs with php. It explains how to use it thoroughly. http://www.phpclasses.org/package/3163-PHP-Generate-GIF-animations-from-a-set-of-GIF-images.html

You can look at my example using this library here: http://cmon.horizon-host.com/gifs/slideshow_normal.php
On the site just select 2 pictures and write 100 for speed 900 for width and height. It will put them in an animated gif slideshow.

Here is the code for that script:

<?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>

As you see it references the GIFEncoder class found on the first link. It also uses some javascript validation and jQuery multiupload.

Note: this question has already been asked.

少钕鈤記 2024-10-12 23:21:21

在您的 css 文件中使用此代码。

#animation {
  -webkit-animation-name: pulse;
  -webkit-animation-duration: 2s;
  -webkit-animation-iteration-count: infinite;
  -webkit-animation-timing-function: ease-in-out;
  -webkit-animation-direction: alternate;
}

在 html 中...

<div id="animation">
    <img src="your image with path">
</div>

如果您的浏览器是 Mozilla Firefox,请将 -webkit- 替换为 -moz-。

玩得开心...

Use this code in your css file.

#animation {
  -webkit-animation-name: pulse;
  -webkit-animation-duration: 2s;
  -webkit-animation-iteration-count: infinite;
  -webkit-animation-timing-function: ease-in-out;
  -webkit-animation-direction: alternate;
}

And in html...

<div id="animation">
    <img src="your image with path">
</div>

If your browser is Mozilla Firefox, replace -webkit- with -moz-.

Have fun...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文