Struggling with arc distortion on a text label

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
highflux
Posts: 2
Joined: 2014-11-22T12:46:52-07:00
Authentication code: 6789

Struggling with arc distortion on a text label

Post by highflux »

Hi! I want to add a text label on an image and to apply arc distort on the label only. Also, I would like to set custom position of the label. So far I just managed to add an arc-distorted label in the image center without any way to control label's position:

convert -page +0+0 $in \( -size 640x360 -gravity center -background none \
-font font.ttf -fill 'red' -pointsize 24 \
label:"some text" -distort Arc '280 0' \) -flatten $out

Input image has dimensions 640x360. Do I have to create an image with the label first and then compose them, or there is a way to do it with one command? Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Struggling with arc distortion on a text label

Post by fmw42 »

You are creating a separate image for the label and compositing it using -flatten. Add another -page before the parens creating the label to tell it where to place it. Or use -gravity -geometry with -composite rather than -flatten. One -page is needed for each image and must go before the image. -geometry goes after the image when used with -composite

convert -page +0+0 $in \
-page +X+Y \( -size 640x360 -gravity center -background none -font font.ttf \
-fill 'red' -pointsize 24 label:"some text" -distort Arc '280 0' \) \
-flatten $out

or

convert $in \
\( -size 640x360 -gravity center -background none -font font.ttf -fill 'red' \
-pointsize 24 label:"some text" -distort Arc '280 0' \) \
-geometry +X+Y -composite $out


see
http://www.imagemagick.org/Usage/layers/#flatten
http://www.imagemagick.org/Usage/layers/#convert
highflux
Posts: 2
Joined: 2014-11-22T12:46:52-07:00
Authentication code: 6789

Re: Struggling with arc distortion on a text label

Post by highflux »

I haven't succeed with the first method (maybe missed something dunno), but the second works fine. I was trying something similar but apparently did not find the correct order of parameters. Thanks a lot!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Struggling with arc distortion on a text label

Post by fmw42 »

Does this work?


convert -page +0+0 $in \
\( -page +X+Y -size 640x360 -gravity center -background none -font font.ttf \
-fill 'red' -pointsize 24 label:"some text" -distort Arc '280 0' \) \
-flatten $out
Post Reply