Search code examples
node.jsgraphicsmagickgm

How do I rotate a text and then draw in graphicsmagick?


How do I rotate a text and then draw in graphicsmagick? It a simple question, but I couldn't understand it from the API.

Help would be appreciated. Thank you. I am using gm by the way, but doing it from the command line is enough also.

Also, there is an open issue about this subject. https://github.com/aheckmann/gm/issues/660

OpenCV or Imagemagick alternative is possible, if we can not do it with graphicsmagick.


Solution

  • I agree with Mark Setchell. The question is ambiguous. In ImageMagick, you can draw rotated text in a number of ways. The -annotate function will do that via its arguments. You can also create a new text image using label: and then rotate that and compose it over your background image. See http://www.imagemagick.org/Usage/text/ and http://www.imagemagick.org/script/command-line-options.php#annotate

    Input:

    enter image description here

    convert logo.jpg -font Arial -pointsize 64 -fill red -gravity center -annotate 20x20+0+0 "TESTING" logo_test.jpg
    

    or alternately using -draw

    convert logo.jpg -font Arial -pointsize 64 -fill red -gravity center -draw "rotate 20 text 0,0 'TESTING'" logo_test2.jpg
    

    enter image description here

    Sorry, I do not know GraphicsMagick, but it should have a similar operator to -annotate and perhaps the same name.