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;
Each image must stay for some 9 seconds without distortion and then quickly transforms into the next image.
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?
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
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
That gives us these guys:
Thought 1
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.
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.
Thought 2
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
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