How to indent text?

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
ClumsyNinja
Posts: 5
Joined: 2013-09-21T18:38:31-07:00
Authentication code: 6789

How to indent text?

Post by ClumsyNinja »

Hi everyone.

I am using IM ImageMagick-6.8.3-Q16 CLI via Macro Scheduler to create thousands of web buttons. The following code works perfectly, except I want to move the text 4 pixels to the right, so it isn't justified up against the left edge. How would I do this, please?

Without the Macro Scheduler code :
convert -background yellow -fill black -size 495x35 -pointsize 31 -gravity west -font Arial-Bold label:TEST 2013-test-yellow2.gif

With the Macro Scheduler code :
run program>"%IMexepath%\convert" -background yellow -fill black -size 495x35 -pointsize 31 -gravity west -font Arial-Bold label:TEST %IMdocpath%\2013-test-yellow2.gif


Many thanks in advance, and thank you for an amazing program!

ClumsyNinja
ImageMagick-6.8.3-Q16 automated with MJTnet Macro Scheduler v14.
Windows 8 64 bit. Sony Vaio laptop.
New to ImageMagic, but an old hat at Windows automation.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to indent text?

Post by snibgo »

There are many ways. One is:

Code: Select all

convert -background yellow -fill black -pointsize 31 -gravity west -font Arial-Bold label:TEST -extent 495x35-4+0 y.gif
One tip, if you don't care exactly how many pixels are used for padding, is to add a space in the label, eg:

Code: Select all

convert -background yellow -fill black -size 495x35 -pointsize 31 -gravity west -font Arial-Bold label:" TEST " 2013-test-yellow2.gif
snibgo's IM pages: im.snibgo.com
ClumsyNinja
Posts: 5
Joined: 2013-09-21T18:38:31-07:00
Authentication code: 6789

Re: How to indent text?

Post by ClumsyNinja »

That's fantastic! Thank you very much. The first solution was perfect.

I ended up using -extent 495x35-3-1 and managed to place the text exactly where I needed it.

This is the final code, in case it helps anyone else.

With Macro Scheduler code (in case anyone else here uses it)

Code: Select all

run program>"%IMexepath%\convert" -background yellow -fill black -size 495x35 -pointsize 31  -gravity west -font Arial-Bold label:%artistname% -extent 495x35-3-1 %IMdocpath%\2012-biggs-collings-yellow2.gif
Without Macro Scheduler code

Code: Select all

convert -background yellow -fill black -size 495x35 -pointsize 31  -gravity west -font Arial-Bold label:TEST -extent 495x35-3-1 c:\TEST.gif
ImageMagick-6.8.3-Q16 automated with MJTnet Macro Scheduler v14.
Windows 8 64 bit. Sony Vaio laptop.
New to ImageMagic, but an old hat at Windows automation.
abs2act
Posts: 10
Joined: 2014-08-12T20:41:45-07:00
Authentication code: 6789

Re: How to indent text?

Post by abs2act »

Is there a way to use different pixel indents if I am using multiple sentences for my image?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to indent text?

Post by fmw42 »

Create each image separately with each line of text and indent as needed. Then append the images vertically (-append). You can add borders to each separate image before appending if you want spacing. See -border or -splice or -extent at http://www.imagemagick.org/Usage/crop/.

You can do this all in one command if you use parenthesis processing. See http://www.imagemagick.org/Usage/basics/#parenthesis
abs2act
Posts: 10
Joined: 2014-08-12T20:41:45-07:00
Authentication code: 6789

Re: How to indent text?

Post by abs2act »

Thanks for the reply fmw42!
Post Reply