Set font size

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
niketa

Set font size

Post by niketa »

I want to set font size automatically. It depends on text length and image height and width. How can I calculate font size like this so that text will be best fit in image.
mkoppanen
Posts: 309
Joined: 2007-06-09T07:06:32-07:00

Re: Set font size

Post by mkoppanen »

niketa wrote:I want to set font size automatically. It depends on text length and image height and width. How can I calculate font size like this so that text will be best fit in image.
Take a look at the Imagick::queryFontMetrics method.
Mikko Koppanen
My blog: http://valokuva.org
niketa

Re: Set font size

Post by niketa »

I was trying to use this method queryFontMetrics(). It gives me Fatal error: Call to undefined method Imagick::QueryFontMetrics()
mkoppanen
Posts: 309
Joined: 2007-06-09T07:06:32-07:00

Re: Set font size

Post by mkoppanen »

Either you are running a very old version of Imagick or you have a typo somewhere.
Mikko Koppanen
My blog: http://valokuva.org
Post Reply