How to find text length in pixels?

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
Posts: 4
Joined: 2012-06-07T00:36:33-07:00
Authentication code: 13

How to find text length in pixels?

Post by cicada »


Need help with the following:

I need to convert the following string to a bmp image:
"Hello World".

The spacing between the words "Hello" and "World" needs to be 20 pixels. How do I accomplish this spacing using MagickWand?

I need to display the text "Hello" with the rightmost end at a distance of 20 pixels from the right edge of the image. Any ideas on how to do this using MagickWand?

Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: How to find text length in pixels?

Post by el_supremo »

The MagickQueryFontMetrics(mw, dw, text) function returns metric information for the given text string from which you can compute where the strings should be placed.
See my fontmetrics example.

Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to find text length in pixels?

Post by anthony »

For command line see..
Determining Font Metrics, without using an API
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
Post Reply