writing text diagonally

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
manit
Posts: 123
Joined: 2009-01-30T22:31:26-07:00

writing text diagonally

Post by manit »

I used the command

convert -size 200x200 xc:white -pointsize 20 -draw "rotate 315 text 0,200 'good'" out.jpg

I was expecting I will get 'good' written starting from bottom left corner towards top right .
Instead the direction is alright but origin point is not as desired .
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: writing text diagonally

Post by Bonzo »

User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: writing text diagonally

Post by fmw42 »

try


convert -size 200x200 xc:white -pointsize 20 -gravity southwest -draw "rotate 315 text 10,10 'good'" tmp.jpg
manit
Posts: 123
Joined: 2009-01-30T22:31:26-07:00

Re: writing text diagonally

Post by manit »

thank you fnw42 . It worked as desired. I believe southwest gravity sets origin to bottom right & starting from 10,10 ensures that no corner of first letter gets cropped .

To bonzo , shearing using annotate seems difficult because firstly there is x degree & y degree.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: writing text diagonally

Post by fmw42 »

manit wrote:thank you fnw42 . It worked as desired. I believe southwest gravity sets origin to bottom right & starting from 10,10 ensures that no corner of first letter gets cropped .

To bonzo , shearing using annotate seems difficult because firstly there is x degree & y degree.

-gravity southwest sets the origin to the bottom left, -gravity southeast sets it to the bottom right and -gravity center will set it to the center, etc

see http://www.imagemagick.org/script/comma ... hp#gravity
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: writing text diagonally

Post by anthony »

In a summery and for completeness for anyone else looking at this problem...

There are four basic ways.
  • create label and rotate
    but if you look at the discussion on the old rotate operator you will find it produces a fairly blurry result.
  • create label and rotate using +distort SRT
    this produces a much sharper result and has other options that allow you to control just how blury the result is. It also lets you do a lot more that just rotate the text.
  • draw the text such as someone else previously showed. The various low level MVG commands let you control the rotation and positioning relative to the rotation. See Text Rotation with Translation for examples.
  • Use Annotate
    which is essentially exactly like the last draw command method but without the complexity, and also allows you to read the text from a file or include image properties (size, comments etc) in the annotated string.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
manit
Posts: 123
Joined: 2009-01-30T22:31:26-07:00

the end

Post by manit »

I understood the annotate operator . It is just that we can rotate x & y axis by as many degrees we want & direction is clockwise.
Post Reply