How to do different -delay after last morph?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
casper

How to do different -delay after last morph?

Post by casper »

If I have 4 images that I want to morph, but delay longer after the last one (before it cycles back), how is that done?

I have it working with this hack, but this is needlessly writing an extra image.

convert \( -delay 60 -morph 1 file1.jpg file2.jpg file3.jpg file4.jpg \) \( -delay 120 file4.jpg \) out.gif


Extra credit:

Say you wanted to "morph 1" the first 3 images but "morph 5" between the 3rd and 4th image, how would that be done?

Thanks.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to do different -delay after last morph?

Post by fmw42 »

I have never used morph before, but have you tried:

convert \( -delay 60 -morph 1 file1.jpg file2.jpg \) \( -delay 120 -morph 5 file3.jpg file4.jpg \) out.gif

This should give you delay 60 for file 1 and 2 each as a frame and delay 120 for five frames between file 3 and 4.

Let us know if that works.
casper

Re: How to do different -delay after last morph?

Post by casper »

Nope... that has two problems...

* image #2 doesn't morph into image #3

* the morph from image #3 to image #4 is slowed down (due to the -delay 120), whereas what I want to do is make that morph happen at the same rate, but then linger on the last image for a while before the whole thing cycles again.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to do different -delay after last morph?

Post by anthony »

So add a morph for between 2 and 3 also in parenthesis.

As the last image in the morphed sequence is the start for the next sequence you do not need to read it again. However you may need to remove the extra duplicate image between the morph sequences...

also you should read images BEFORE morphing them!!!

Code: Select all

convert file1.jpg
       \( +clone -set delay 60 file2.jpg -morph 1 -delete 0 \) \
       \( +clone -set delay 60 file3.jpg -morph 3 -delete 0 \) \
       \( +clone -set delay 60 file4.jpg -morph 5 -delete 0 \) \
       -layers Optimize out.gif
Note it is the delay setting for the first image that sets the delay of the generated morphed image (I think, can someone verify).

Also note that while I optimize the results, unless parts of the image don't change color a morph does not optimize very well.

The -morph operator is more like a repeated -blend operation
See http://imagemagick.org/Usage/compose/#blend

A True morph not only involves a color blend, but also a spatial distortion, generally defined using two related meshes of distortion control points, See the problem 'Xmorph'.

This type of morph is almost within the graph of IM's general distortion operator, only requiring a mesh distortion method to be added (I haven't had time to do this yet).

For reversing a existing animation, see IM examples Animation modifiactions, Reversing
http://imagemagick.org/Usage/anim_mods/#reverse
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply