Annotate with FX expression using IM6

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Annotate with FX expression using IM6

Post by GeeMack »

Using IM 6.9.9-20 Q16 x64 HDRI with Windows 10, I get an unexpected result when running this command...

Code: Select all

convert -size 64x64 xc: xc: xc: -gravity northwest ^
   -pointsize 24 -annotate +0+0 "%[fx:t+1]" +gravity -crop 2x1@ out6.png
The command should create three canvases, annotate them with numbers 1, 2, and 3, then crop each canvas into halves. The actual output is these six panels (which I've appended for display)...

Image

Annotate is numbering the panels 1, 3, and 5 as if it's counting relative to the six images in the stack after the crop, even though the annotate operation occurs before the crop and should only affect the original three images.

If I run the same command with IM 7.0.7-8 by substituting "magick" for "convert", the output is as expected with the panels numbered 1, 2, and 3.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Annotate with FX expression using IM6

Post by fmw42 »

I do not think annotate permits fx expressions in IM 6 for the text. However, it does allow escapes such as %w, but not %{fx:w]
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Annotate with FX expression using IM6

Post by GeeMack »

fmw42 wrote: 2017-10-15T21:43:11-07:00I do not think annotate permits fx expressions in IM 6 for the text. However, it does allow escapes such as %w, but not %{fx:w]
I haven't found any descriptions of how "-annotate" handles FX expressions in IM6, but I have tested many variations, and pretty much everything I try seems to work as expected. Even back to version 6.7.7 on bash this would print "Test: 1256.64 200 72"...

Code: Select all

convert -size 400x100 xc: -gravity northwest \
   -annotate +0+0 "Test: %[fx:w*pi] %[fx:w>100?200:300] %[fx:resolution.x]" output.png
The documentation just below THIS link suggests FX expressions should work for at least "label:" and "caption:" since v6.3.2. I suppose the fact that it works for most expressions using "-annotate ..." and IM6 may be unintended.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Annotate with FX expression using IM6

Post by fmw42 »

I stand corrected. If you have found that it works with fx expressions, then the issue is which "letters" it is coded for. Perhaps %[fx:t] is not coded whereas %[fx:w] does work. In that past, I had to ask that other letters be included in certain places, but I do not recall which letters or in which functions.
Post Reply