Image Size and Font Size

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
rajan
Forum Contributor
Posts: 110
Joined: Sun Aug 28, 2005 7:42 pm
Location: Lucknow, UP, India

Image Size and Font Size

Post by rajan »

I want an option that user can enter text and height or width of the image. On the basis of height/width and no of characters of text I want to calculate width/height of the image and font size which fits in this dimension of image. How can we do this?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

There are GD functions you can use to determine the width of a string of text.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
rajan
Forum Contributor
Posts: 110
Joined: Sun Aug 28, 2005 7:42 pm
Location: Lucknow, UP, India

Post by rajan »

How can I do this? I have only image width, font file and text . Using this I have to calculate image height and font size. imagefontwidth() and imagefontheight() take fontsize as paramater and value must be between 1-5 and I have to calculate fontsize. Can somebody tell me how can I do this?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

imagettfbbox() may be of interest.
Post Reply