How can I auto adjust the width of a GD-generated image to fit the text?

不打扰是莪最后的温柔 提交于 2019-12-11 08:54:44

问题


I'm trying to display a number using GD. This number changes, so sometimes the width needs to change. Is there a way to calculate how wide the text will be so that I can dynamically set the width?


回答1:


Yes, you can find out the dimensions of a text using imagettfbbox() (or imageftbbox() if you're using Freetype).



来源:https://stackoverflow.com/questions/4485630/how-can-i-auto-adjust-the-width-of-a-gd-generated-image-to-fit-the-text

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!