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:
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):and we can do likewise for green to blue with
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:
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: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: