Code: Select all
convert rose: -duplicate 3 -set page "+%[fx:w/(n-1)]+0" ( +clone -write tmp.png +delete ) output.gif
Code: Select all
convert.exe: divide by zero `w/(n-1.0*1)' @ error/fx.c/FxEvaluateSubexpression/2178.
Code: Select all
convert rose: -duplicate 3 -set page "+%[fx:w/(n-1)]+0" ( +clone -write tmp.png +delete ) output.gif
Code: Select all
convert.exe: divide by zero `w/(n-1.0*1)' @ error/fx.c/FxEvaluateSubexpression/2178.
The command produces the expected result other than the error message. It doesn't squawk if I use any of these FX expressions...fmw42 wrote: 2018-01-22T11:42:02-07:00I do not think you can do that in IM 6. It works fine in IM 7 and fails for me in IM 6. I do not think -set page knows about %n in IM 6. If you substitute 4 in for n, then it works in IM 6. That confirms it to me.
Code: Select all
... %[fx:w/n] ...
... %[fx:w/(n+1)] ...
... %[fx:w/(n-2)] ...
I would think resetting the paging information inside the parentheses with "+repage", "+set page", or "-set page +0+0" might prevent that, but apparently the calculation sticks with that clone all the way up to, but not including, the output.snibgo wrote: 2018-01-22T13:14:22-07:00I don't understand the mystery. Within the parentheses, the number of images is one. So n=1, and n-1=0, so there is a divide by zero. This is evaluated only if needed, such as when the output is a PNG.
The error message is a bit weird, I assume because IM has tokenised the expression, and is de-tokenising it for the message. But that evaluates to the same, n-1*1, so it is still zero.
Code: Select all
convert rose: -duplicate 3 -set page "+%[fx:w/(n-1)]+0" ( +clone +repage -write tmp.png +delete ) output.gif
convert.exe: divide by zero `w/(n-1.0*1)' @ error/fx.c/FxEvaluateSubexpression/2178.
Code: Select all
f:\web\im>%IM%convert rose: -duplicate 3 ( +clone -format "N=%n\n" -write info:
+delete ) info:
N=1 <== this is the output from within the parenthesis.
N=4
N=4
N=4
N=4The string expression isn't expanded until it is needed. This is more clearly seen with "-format", and I assume "-set page" works in the same way, so it substitutes values as appropriate to each image. For example:GeeMack wrote:I would think resetting the paging information inside the parentheses with "+repage", "+set page", or "-set page +0+0" might prevent that, but apparently the calculation sticks with that clone all the way up to, but not including, the output.
Code: Select all
f:\web\im>%IM%convert rose: -duplicate 3 ( +clone -resize 200% -format "W=%w; N=%n\n" -write info: +delete ) info:
W=140; N=1
W=70; N=4
W=70; N=4
W=70; N=4
W=70; N=4It seems the need for the calculation might be eliminated by resetting the paging for that one image inside the parentheses using one of these methods, but they all generate the same error message.snibgo wrote: 2018-01-22T16:58:00-07:00Except that the computation isn't done then. The page is merely set to a string, and the string isn't expanded until it is needed.
Code: Select all
convert rose: -duplicate 3 -set page "+%[fx:w/(n-1)]+0" ( +clone -set page +0+0 -write tmp.png +delete ) output.gif
convert rose: -duplicate 3 -set page "+%[fx:w/(n-1)]+0" ( +clone -set page "+%[fx:w/2]+0" -write tmp.png +delete ) output.gif
convert rose: -duplicate 3 -set page "+%[fx:w/(n-1)]+0" ( +clone +repage -write tmp.png +delete ) output.gif
convert rose: -duplicate 3 -set page "+%[fx:w/(n-1)]+0" ( +clone +set page -write tmp.png +delete ) output.gif
Code: Select all
convert rose: -duplicate 3 ( +clone -set page "+%[fx:w/2]+0" -write tmp.png +delete ) -set page "+%[fx:w/(n-1)]+0" output.gifUsers browsing this forum: Amazon [Bot] and 14 guests