rotate the text with angle

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
tczf1128
Posts: 28
Joined: 2018-12-04T22:47:49-07:00
Authentication code: 1152

rotate the text with angle

Post by tczf1128 »

Code: Select all

convert -size 140x80 xc:none -fill black -gravity northwest -draw "text 20,20 'copyright'"   -gravity southeast -draw "text 10,20 'copyright'"           miff:- |    composite -tile - out.png  wmark_text_tiled.png
I tile text on a image using this command, how can I roate the text with angle
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: rotate the text with angle

Post by fmw42 »

Pleases always provide your ImageMagick version and platform and your input images.

What you need to do is use -annotate to create the text at an angle or use -rotate to rotate the text you have created with -draw. You can also do it all in one convert command line rather than piping to composite.

_______________


See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli


For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: rotate the text with angle

Post by fmw42 »

Here is how I do it. I create the rotated white text on a transparent background with -annotate. Then I save that as an in memory MPR: image. Then I tile it over the background image so that it replaces the background image. That way I do not need to know how big the background image was. Then I composite that over the background image.

Image

Code: Select all

convert barn.jpg \
\( -size 140x80 xc:none \
-fill white -pointsize 28 \
-gravity center \
-annotate +10x10 "TESTING" \
-write mpr:text +delete  \
barn.jpg -background none \
-fill mpr:text -draw 'color 0,0 reset' \) \
-compose over -composite \
barn_text.png

Image


See tiling https://imagemagick.org/Usage/canvas/#tile_memory and parenthesis processing at https://imagemagick.org/Usage/basics/#parenthesis and convert compositing at https://imagemagick.org/Usage/compose/#compose

See the note about tiling transparent images at https://imagemagick.org/Usage/canvas/#tile, which requires adding -background none (or -compose src)
tczf1128
Posts: 28
Joined: 2018-12-04T22:47:49-07:00
Authentication code: 1152

Re: rotate the text with angle

Post by tczf1128 »

Sorry, I forgot the IM version. IM v7.0.8

Your code is great, but I find it a little difficult for me to translate the command to magickWand API
tczf1128
Posts: 28
Joined: 2018-12-04T22:47:49-07:00
Authentication code: 1152

Re: rotate the text with angle

Post by tczf1128 »

Do you know how to translate your command into magickwand api?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: rotate the text with angle

Post by fmw42 »

tczf1128 wrote: 2019-02-24T20:34:01-07:00 Do you know how to translate your command into magickwand api?
No, sorry, I do not use any API, just the command line.
tczf1128
Posts: 28
Joined: 2018-12-04T22:47:49-07:00
Authentication code: 1152

Re: rotate the text with angle

Post by tczf1128 »

using my command, how to add params to let the text rotate?

Code: Select all

convert -size 140x80 xc:none -fill black -gravity northwest -draw "text 20,20 'copyright'"   -gravity southeast -draw "text 10,20 'copyright'"           miff:- |    composite -tile - out.png  wmark_text_tiled.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: rotate the text with angle

Post by fmw42 »

-draw does not support rotated text. But you can add -background none -rotate 10 -gravity center -extent 140x80 after you have drawn the text just before the miff:-

See if that works. You did not provide your input images, so I could not test that.
tczf1128
Posts: 28
Joined: 2018-12-04T22:47:49-07:00
Authentication code: 1152

Re: rotate the text with angle

Post by tczf1128 »

It's my input image
Image

Code: Select all

convert -size 140x80 xc:none -fill black -gravity northwest -draw "text 20,20 'copyright'"   -gravity southeast -draw "text 10,20 'copyright'"  -background none -rotate 10 -gravity center -extent 140x80          miff:- |    composite -tile - out.png  wmark_text_tiled.png
is it ok?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: rotate the text with angle

Post by fmw42 »

Your result looks OK to me. Is that not what you want?
tczf1128
Posts: 28
Joined: 2018-12-04T22:47:49-07:00
Authentication code: 1152

Re: rotate the text with angle

Post by tczf1128 »

yes. thanks so much. and I already translate it to api
Post Reply