You have to put the text in a separate image, then rotate that. Afterwards you will place the text on the image.
Annotate can rotate text, but it rotates around the placement handle, which depends on Gravity.
You want to center some rotated text on the left edge directly -- forget it. It is simplier to rotate the image place the text and rotate back.
{rant on}
Gravity is used for placement, but it also defines the 'handle' with in the object that is being placed. Typically this is the justification position. The two are different, and yet in IMv6 they are controled by the same variable. IMv7 to-do includes separation of these two items
{rant off}
Distort is particually good for placing rotated text using a handle. that is because, you can define the handle in terms of a position both in the original and final text.
This will be a future IM Example...
Distorted Placement of Text
Code: Select all
convert logo: -pointsize 36 -background none label:'Some Text' \
-flatten show:
Okay some text is added to image (using a layers method) at top left corner.
Lets rotate it using distort (layers varient) -- Not the use of parenthesis to limit what image we distort!
Code: Select all
convert logo: \( -pointsize 36 -background none label:'Some Text' \
+distort SRT 70 \
\) -flatten show:
Note that the text position was NOT changed! All that happens was that in layers mode the text was simply rotated around the default handle, the center point.
The next step is to move that handle, but for this we need to use almost the FULL SRT distort specification.
http://www.imagemagick.org/Usage/distort/#srt
Because we need to define the 'center handle' as well we need to use some percent escapes,
http://imagemagick.org/script/escape.php
specifically FX percent escapes
http://imagemagick.org/script/fx.php
So lets place the center at +100+100 in the background image
Code: Select all
convert logo: \( -pointsize 36 -background none label:'Some Text' \
+distort SRT '%[fx:w/2],%[fx:h/2] 1 70 100,100' \
\) -flatten show:
Better, but what if you want to place a 90 degree rotated test on the right edge.
The handle of the text to rotate around and position will be the center bottom: %[fx:w/2],%h
But to get the center left edge: 0,%[fx:h/2] we need to get it from the background image which distort does not have access to.
This needs a special trick to extract information from other images....
http://www.imagemagick.org/Usage/transform/#fx_other
Here is the solution
Code: Select all
convert logo: -set option:my:left_edge '0,%[fx:h/2]' \
\( -pointsize 36 -background none label:'Some Text' \
+distort SRT '%[fx:w/2],%h 1 90 %[my:left_edge]' \
\) -flatten show:
The "my:" string can be anything that does nto clash with existing prefixes, and is used to keep MY settings, separate to other settings ImageMagick may use for coders or specific options. "my:" is a good choice.
This is purely string substitutions. and in fact we could generate the whole Distort option as a string. The only problem is you can not do math on strings, at least not in IMv6, so any math much be does before hand.
This has been added to IM Examples at...
http://www.imagemagick.org/Usage/annotating/#distort