Page 1 of 1

rotate the text with angle

Posted: 2019-02-24T05:14:11-07:00
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

Re: rotate the text with angle

Posted: 2019-02-24T12:14:23-07:00
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

Re: rotate the text with angle

Posted: 2019-02-24T12:37:33-07:00
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)

Re: rotate the text with angle

Posted: 2019-02-24T20:18:11-07:00
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

Re: rotate the text with angle

Posted: 2019-02-24T20:34:01-07:00
by tczf1128
Do you know how to translate your command into magickwand api?

Re: rotate the text with angle

Posted: 2019-02-24T20:45:23-07:00
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.

Re: rotate the text with angle

Posted: 2019-02-24T21:30:53-07:00
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

Re: rotate the text with angle

Posted: 2019-02-24T21:50:44-07:00
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.

Re: rotate the text with angle

Posted: 2019-02-24T22:29:36-07:00
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?

Re: rotate the text with angle

Posted: 2019-02-24T23:59:13-07:00
by fmw42
Your result looks OK to me. Is that not what you want?

Re: rotate the text with angle

Posted: 2019-02-25T01:07:34-07:00
by tczf1128
yes. thanks so much. and I already translate it to api