多个图像之间的Imagemagick过渡-需要想法 [英] Imagemagick transitions between multiple images -- need idea

查看:105
本文介绍了多个图像之间的Imagemagick过渡-需要想法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Fred的Imagemagick脚本,特别是 fxtransitions 来创建过渡两个图像之间的效果.我正在创建jpeg图像帧.稍后,我将使用ffmpeg将它们转换为视频.这是我使用Imagemagick的第三天,目前,我可以使用以下脚本在两个图像之间成功应用过渡效果.但是,我还需要满足以下两个条件:

I am using Fred's Imagemagick scripts, particularly, fxtransitions to create a transition effect between two images. I am creating jpeg image frames. Later, I will use ffmpeg to turn them into video. It is my third day with Imagemagick and currently I can successfully apply the transition effect between two images with the following script. However, I also need to meet two following criteria:

$result = shell_exec("bash /cygdrive/path/to/fxtransitions -e  explode -f 50 -d 1 -p 1 -r first.jpg second.jpg output.jpg"); 
echo $result;

  1. 每张图像必须保持约9秒钟而不变形,然后快速转换为下一张图像.

  1. Each image must stay for some 9 seconds without distortion and then quickly transforms into the next image.

当前,Fred的脚本允许两个图像输入.脚本中可以使用两个以上的图像吗?如何使用php循环遍历多个图像?

Currently, Fred's script allows two image inputs. Is it possible to use more than two images within the script? How can I loop through multiple images with php?

推荐答案

不确定使用ImageMagick在三天内收集到的内容-它是一款功能强大的软件,您可能会花一生的时间.无论如何,让我们制作一些动画,看看我的漫步是否可以帮助您.

Not sure what you have managed to gather in 3 days with ImageMagick - it is such a capable piece of software that you could spend a lifetime on it. Anyway, let's make some animations and see if my ramblings can help you out.

首先,我们制作一个红色,绿色和蓝色的图像以供播放:

First, we make a red, green and a blue image to play with:

convert -size 100x100 xc:red    r.png
convert -size 100x100 xc:green  g.png
convert -size 100x100 xc:blue   b.png

然后,我们通过8个中间步骤将红色从绿色变为绿色,总共生成10张图像,然后将它们拍成动画序列,并在帧之间延迟20厘秒,将其拍打起来,将其称为r2g.gif(红色到-绿色):

Then we morph from the red to the green with 8 intermediate steps, for a total of 10 images and slap them together in an animated series with a 20 centisecond delay between frames and call it r2g.gif (for red-to-green):

convert -delay 20 r.png g.png -morph 8 r2g.gif   # Make 10 frame morph called "r2g.gif"

identify r2g.gif                                 # look at frames
r2g.gif[0] GIF 100x100 100x100+0+0 8-bit sRGB 2c 1.74KB 0.000u 0:00.000
r2g.gif[1] GIF 100x100 100x100+0+0 8-bit sRGB 2c 1.74KB 0.000u 0:00.000
r2g.gif[2] GIF 100x100 100x100+0+0 8-bit sRGB 2c 1.74KB 0.000u 0:00.000
r2g.gif[3] GIF 100x100 100x100+0+0 8-bit sRGB 2c 1.74KB 0.000u 0:00.000
r2g.gif[4] GIF 100x100 100x100+0+0 8-bit sRGB 2c 1.74KB 0.000u 0:00.000
r2g.gif[5] GIF 100x100 100x100+0+0 8-bit sRGB 2c 1.74KB 0.000u 0:00.000
r2g.gif[6] GIF 100x100 100x100+0+0 8-bit sRGB 2c 1.74KB 0.000u 0:00.000
r2g.gif[7] GIF 100x100 100x100+0+0 8-bit sRGB 2c 1.74KB 0.000u 0:00.000
r2g.gif[8] GIF 100x100 100x100+0+0 8-bit sRGB 2c 1.74KB 0.000u 0:00.000
r2g.gif[9] GIF 100x100 100x100+0+0 8-bit sRGB 2c 1.74KB 0.000u 0:00.000

我们也可以将绿色变成蓝色

and we can do likewise for green to blue with

convert -delay 20 g.png b.png -morph 8 g2b.gif

这给了我们这些家伙:

思想1

我想告诉你的第一件事是,您可以将动画GIF与ImageMagick串联在一起,如下所示:

The first thing I wanted to tell you is that you can concatenate animated GIFs together with ImageMagick like this:

convert r2g.gif g2b.gif both.gif

所以您首先要从红色变成绿色,然后再从绿色变成蓝色.

so that you go first from red to green, and then from green on to blue.

关键是,如果您使用Fred的脚本,则可以将动画A 加入动画B .因此,只要可以在2个点之间进行动画处理(可以),就可以通过连接两个动画来对第3点进行动画处理,因此您不需要在Fred的脚本中传递2个以上的点.

The point is that, if you use Fred's scripts, you can join animation A to animation B. So, as long as you can animate between 2 points (which you can), you can animate to a third point by concatenating two animations therefore you don't need to pass more than 2 points to Fred's scripts.

思想2

-delay参数是一个设置,而不是一个操作,因此它将一直保持设置状态,直到命令结束或您对其进行更改为止.因此,您可以将帧延迟延长一帧,然后再将其延迟为较短的时间,以用于后续的帧,如下所示:

The -delay parameter is a setting not an operation, so it stays set until the end of the command or until you change it. So you can make the frame delay long for one frame and then revert to a shorter time for subsequent frames like this:

convert -delay 300 r2g.gif[0]    \
        -delay 20 r2g.gif        \
        -delay 300 g2b.gif[0]    \
        -delay 20 g2b.gif        \
        staccato.gif

基本上,我们将动画的第一帧暂停3秒钟,并将红绿和绿蓝动画之间的过渡帧也保持3秒钟,而将其他帧周期保留为20厘秒.您还应该注意,我们可以通过将动画的各个帧放在文件名后的方括号中并使用-1指示最后一个帧来处理动画的各个帧.

Essentially, we are pausing the first frame of the animation for 3 seconds, and holding the transition frame between the red-green and the green-blue animation also for 3 seconds whilst leaving the other frame periods at 20 centiseconds. You should also note that we can address individual frames of the animation by putting them in square brackets after the filename, and using -1 to indicate the last frame.

您现在可以检查由上一条命令引起的各个帧之间的时间/延迟,如下所示:

You can now inspect the times/delays between the individual frames as caused by the previous command like this:

identify -format "%f[%s] %T\n" anim.gif 
anim.gif[0] 300   <--- first frame has 3 second frame time
anim.gif[1] 20
anim.gif[2] 20
anim.gif[3] 20
anim.gif[4] 20
anim.gif[5] 20
anim.gif[6] 20
anim.gif[7] 20
anim.gif[8] 20
anim.gif[9] 20
anim.gif[10] 20
anim.gif[11] 300  <--- first frame of second animation also held for 3 seconds
anim.gif[12] 20
anim.gif[13] 20
anim.gif[14] 20
anim.gif[15] 20
anim.gif[16] 20
anim.gif[17] 20
anim.gif[18] 20
anim.gif[19] 20
anim.gif[20] 20
anim.gif[21] 20

这篇关于多个图像之间的Imagemagick过渡-需要想法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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