I am developing a script in PHP, to write on top of some images, what I need is that the text that the user enters occupies 100% of the width of the image, I have tried with something like this:
$tam_fuente=floor($width/$cant_caracteres);
Where $ width is the width (in pixels) of the image and $ cant_characters, is the number of characters that the user wrote, I get it with strlen (). But the result does not achieve what I'm looking for. Is it possible to do what I want? Thanks
I have managed to do it with a loop, I do not think it's the best but I'm staying like this:
$tam_texto=imagettfbbox (12,0,$fuente,$string);
for($i=13;$tam_texto[2]<=$width && $i<$height;$i++)
{
$tam_texto=imagettfbbox ($i,0,$fuente,$string);
if($tam_texto[2]<$width)
{
$tam_fuente=$i;
}
}