<A NAME="layer_distort_placement"></A>
<H3>Distorted Placement using Layers</H3>

Distort is particually good for placing rotated text or images, based on a
specific point.

<PRE>
  convert logo:  -pointsize 36 -background none label:'Some Text' \
          -flatten  show:
</PRE>

Okay some text is added to image (using a layers method) at top left corner.
</P>

Lets rotate it using distort (layers varient) -- Not the use of parenthesis to
limit what image we distort!

<PRE>
  convert logo: \( -pointsize 36 -background none label:'Some Text'  \
             +distort SRT 70 \
          \) -flatten  show:
</PRE>

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. </P>

The next step is to move that handle, but for this we need to use almost the
full set of <A HREF="../distort/#srt" >SRT Distorton</A> arguments. </P>

Because we need to define the 'center handle' as well we need to use some <A
HREF="http://imagemagick.org/script/escape.php" >Image Properity Percent
Escapes</A>, or more specifically <A HREF="../transform/#fx_escapes" >FX
Percent Escapes</A>. </P>

So lets place the center at +100+100 in the background image

<PRE>
  convert logo: \( -pointsize 36 -background none label:'Some Text'  \
             +distort SRT '%[fx:w/2],%[fx:h/2] 1 70 100,100' \
          \) -flatten  show:
</PRE>

Better, but what if you want to place a 90 degree rotated test on the right
edge. </P>

The handle of the text to rotate around and position will be the center
bottom '<CODE>%[fx:w/2],%h</CODE>' of the 'text image'. </P>

But the center left edge '<CODE>0,%[fx:h/2]</CODE>' must be calculated from
background image.  But this image is not available when we are making our call
to distort.  To fix this we need to Extract the position from the background
image, and save it for later use.

Here is the solution...

<PRE>
  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:
</PRE>

The '<CODE>my:</CODE>' prefix string in the above is just something to ensure
my saved setting does not interfer with other settings IM may use.
I recommend using '<CODE>my:</CODE>' prefix as a good choice. </P>

That percent escapes are purely string substitutions.  The only problem with
this is you can not do any math on strings after that have been set.  But
their are plans to fix this in IMv7. </P>



