NEED: Command line utility to get graphics dimensions of text output in a specified font

C

Carol Haynes

Does anyone know of a command line utility that can work out the dimensions
of a piece of text when rendered in a specified font.

What I am trying to do is use ImageMagick to produce a graphical image of a
piece of text, but I need to specify the size of graphic to create and the
fontsize as command line options. I could just go mad and make a huge image
and then manually crop it but ideally I would like to automate the process
for multiline text.

TIA
 
L

lisztfr

XNview with capture screen ?

Hm ok, one could try to write your text to html prior to
use image magic. You can set any kind of text size in
the html document, also some effects, then take a screen
capture of all that in jpg. No ?

laurent
 
C

Carol Haynes

Thanks for the thought. Yes that is possible if I want to do this
automatically - but it doesn't solve the working out the size problem
automatically. Once it is in an HTML document I still don't know how big it
is - I would have to manually capture the image, crop it to the actually
text and then look at the file details.

Ideally I want to build a batch file in the style:

process.bat <text> <font> <Final image size> <imagefile>

where text is the text (line breaks can be \n in the text).

The image will be created big enough to contain the text at a large
fontsize - the lines of processed text stuck together to make a whole image,
and the final image scaled to the required output size

One of the things ImageMagick can do is process the text to produce some
really nice effects so I don't want to print the text and capture it because
then I can't process the live text any more. In order to create an image
with IM I need to guess the size of the image - especially the width of the
graphic so that it has a rectangular template to output the file into.

Carol
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top