Page 1 of 1

Distort animation without the -duplicate command?

Posted: 2012-02-10T09:52:13-07:00
by lonk
Hi everyone,

I'm using an old version of IM that does not have the duplicate command (version 6.6.0-4, because it is the only available version on my platform, maemo OS and using N900)

I would like to create a tile that animates like this

Image

using this command

Code: Select all

convert rose:  -duplicate 29  -virtual-pixel tile \
          -distort SRT '0,0 1, 0, %[fx:w*t/n],%[fx:h*t/n]' \
          -set delay 10 -loop 0     rose_diagonal_roll.gif
I read on the tutorial that I can use the clone command, but I don't know how to use it in this case.


Thanks for any help

Re: Distort animation without the -duplicate command?

Posted: 2012-02-10T10:58:47-07:00
by fmw42
convert rose: -clone 0 -clone 0 -clone 0 ....[29times].... -clone 0 -virtual-pixel tile \
-distort SRT '0,0 1, 0, %[fx:w*t/n],%[fx:h*t/n]' \
-set delay 10 -loop 0 rose_diagonal_roll.gif

Re: Distort animation without the -duplicate command?

Posted: 2012-02-10T11:24:14-07:00
by lonk
thanks for the help, but alas no success, it only shows the rose frame still and doesn't move.

I looked at the tutorial again and it mentions this (apologies for not seeing this it before as it's also relevant to my problem of using old version):

Code: Select all

Before IM v6.6.9-0 Percent Escapes and FX Percent Escapes involving image indexes, such as '%p', '%n', '%[fx:t]' and '%[fx:n]' were broken. Typically they would only return unhelpful values of either '0' or '1', and not the actual index and number of images in the current image sequence.


So I'm guessing I just can't do it with this version?

Re: Distort animation without the -duplicate command?

Posted: 2012-02-10T12:32:31-07:00
by fmw42
Either of these should work or Linux/Mac (unix), though they may be a bit slower than the duplicate method.


ww=`convert rose: -format "%w" info:`
hh=`convert rose: -format "%h" info:`
convert rose: -delay 10 rose_anim.gif
for ((i=1; i<29; i++)); do
ii=`convert xc: -format "%[fx:-$ww*(1-$i/29)]" info:`
jj=`convert xc: -format "%[fx:-$hh*(1-$i/29)]" info:`
convert rose_anim.gif -delay 10 \( rose: -virtual-pixel tile -distort SRT "0,0 1, 0, $ii,$jj" \) rose_anim.gif
done
convert rose_anim.gif -loop 0 rose_anim.gif

or

ww=`convert rose: -format "%w" info:`
hh=`convert rose: -format "%h" info:`
( for ((i=0; i<29; i++)); do
ii=`convert xc: -format "%[fx:-$ww*(1-$i/29)]" info:`
jj=`convert xc: -format "%[fx:-$hh*(1-$i/29)]" info:`
convert -delay 10 rose: -virtual-pixel tile -distort SRT "0,0 1, 0, $ii,$jj" miff:-
done ) |
convert - -loop 0 rose_anim2.gif

If you do not need the fractional pixel accuracy, you can substitute -roll for -virtual-pixel tile -distort SRT

see
http://www.imagemagick.org/script/comma ... h7b33#roll

Re: Distort animation without the -duplicate command?

Posted: 2012-02-10T14:34:44-07:00
by lonk
This is the result I get for both of the scripts:

Image


And with subsituting with -roll

Image



I don't know why it does that with -virtual-pixel tile -distort SRT (yet again old version problem maybe)

many thanks, fmw42

Re: Distort animation without the -duplicate command?

Posted: 2012-02-10T16:41:20-07:00
by fmw42
Your first one seems to be getting -virtual-pixel edge (default) rather than tile.

Your second one seems to be using integer values rather than float for the offsets.


These are what I got with IM 6.7.5.3 Q16 Mac OSX Snow Leopard

Image

Image


I have no idea why you cannot achieve the same results. My guess is the IM version and limitations on -distort and -virtual-pixel in the earlier versions. I would recommend that you upgrade and then you can use your original method.

Re: Distort animation without the -duplicate command?

Posted: 2012-02-12T07:06:26-07:00
by anthony
Note -roll can only roll using integer values (whole pixel movements). Distort can translate images with sub-pixel movements making the result much smoother, but with pixel neighbour 'color mixing' in the results.

However as -duplicate fails (added M v6.6.8-7) . Then your IM also definitely too old for the FX 't' variable.

As I noted in that example, IM Examples, Animation Modifications, Animated Distorts
Before IM v6.6.9-0 Percent Escapes and FX Percent Escapes involving image indexes, such as '%p', '%n', '%[fx:t]' and '%[fx:n]' were broken. Typically they would only return unhelpful values of either '0' or '1', and not the actual index and number of images in the current image sequence.
In fact it was the creation of -duplicate that actually forced the fixing of the buggy 'image index in percent escapes'

In fact it was something that was 'wanted' for a long time, but I had to wait until I could do-it-myself when I had time (which is rare these days). Implementation actually required a large scale code change on how 'simple operations' such as -distort -set work. Specifically to treat individual images as part of a larger list of images, rather then extract each image singly to process it!

ASIDE: right now I am re-working the same code again for IMv7 CLI development.


Alternatives for -duplicate are given in the IM Examples for duplicate...
http://www.imagemagick.org/Usage/basics/#duplicate

Multiple clones is one method. the other is to fake it using '-morph'. For example make 5 copies of image.gif and append them...

Code: Select all

convert image.gif \( +clone \) -morph 3  +append seq_dup_morph.gif
This however is not as 'efficent' as clones or duplicate, but you actually can give a 'number' (total-2)