Page 1 of 1

the -annotate option is not parsing percent escapes

Posted: 2016-02-09T13:07:57-07:00
by atariZen
When -annotate is supplied a variable for the X offset, it ignores the whole coordinate. Yet it's able to do substitutions in the text message. E.g.

Code: Select all

convert magick:logo -set option:rt '%[fx:W/2-20]' \( -fill black -gravity center -annotate 90,90+%[rt]+0 "dimensions are %Wx%H and rt is %[rt]" \) -gravity east miff:- | display -
The %[rt] causes the argument to be ignored, so text string ends up in the middle of the image (it should be rotated 90 degrees and on the far right edge). If the X offset ("300") is hard-coded, then it does what it should:

Code: Select all

convert magick:logo -set option:rt '%[fx:W/2-20]' \( -fill black -gravity center -annotate  90,90+300+0 "dimensions are %Wx%H and rt is %[rt]" \) -gravity east miff:- | display -

Re: the -annotate option is not parsing percent escapes

Posted: 2016-02-09T16:45:57-07:00
by fmw42
I do not believe that -annnotate offsets can be specified as a -set argument in IM 6. The text can be, however.

You can do this:

Code: Select all

convert logo: -set myinfo "+%[fx:w/2]+%[fx:h/2]" -fill black -gravity west -font arial -pointsize 36 -annotate +0+0 "%[myinfo]" show
But you cannot do this:

Code: Select all

convert logo: -set myinfo "+%[fx:w/2]+%[fx:h/2]" -fill black -gravity west -font arial -pointsize 36 -annotate "%[myinfo]" "%[myinfo]" show:
The same for -set option:myinfo

Similarly, when avoiding the -set and using the % calculations direction, this works:

Code: Select all

convert logo: -fill black -gravity west -font arial -pointsize 36 -annotate +0+0 "+%[fx:w/2]+%[fx:h/2]" show:
But this does not:

Code: Select all

convert logo: -fill black -gravity west -font arial -pointsize 36 -annotate "+%[fx:w/2]+%[fx:h/2]" "%wx%h" show:

But you can do these in IM 7, such as the following that does work.

Code: Select all

magick logo: -fill black -gravity northwest -font arial -pointsize 36 -annotate "+%[fx:w/8]+%[fx:h/2]" "%wx%h" show: