Image: Calculating textwidth

Created on 13 Mar 2014  路  7Comments  路  Source: Intervention/image

It would be great to have a function to calculate the textwidth to create a dynamic image which depends on the textwidth.

Most helpful comment

$font = new \Intervention\Image\Font('foo');
$font->valign('top');
$size = $font->getBoxSize();
$image = new \Intervention\Image\Image(null, $size['width'], $size['height']);
$font->applyToImage($image);
$image->save('foo.png');

How to integrate this in Laravel ?

All 7 comments

With the latest release this is possible:

$font = new \Intervention\Image\Font('foo');
$font->valign('top');
$size = $font->getBoxSize();
$image = new \Intervention\Image\Image(null, $size['width'], $size['height']);
$font->applyToImage($image);
$image->save('foo.png');

Great! I'll check out. If you want i'll suggest some more features which would nice to have. There is so much more potential in this great library. :)

Go ahead. Proposals are always welcome.

$font = new \Intervention\Image\Font('foo');
$font->valign('top');
$size = $font->getBoxSize();
$image = new \Intervention\Image\Image(null, $size['width'], $size['height']);
$font->applyToImage($image);
$image->save('foo.png');

this is really awesome feature.

please can you tell me how can i use this with Laravel??

imagettfbbox will help you

$font = new \Intervention\Image\Font('foo');
$font->valign('top');
$size = $font->getBoxSize();
$image = new \Intervention\Image\Image(null, $size['width'], $size['height']);
$font->applyToImage($image);
$image->save('foo.png');

How to integrate this in Laravel ?

@vinodjoshi you can use it as:

$font = new \Intervention\Image\Gd\Font('foo');
$font->valign('top');
$size = $font->getBoxSize();
Was this page helpful?
0 / 5 - 0 ratings

Related issues

kivivuori picture kivivuori  路  8Comments

ludo237 picture ludo237  路  8Comments

johnvoncolln picture johnvoncolln  路  7Comments

mavinothkumar picture mavinothkumar  路  6Comments

DrDeath72 picture DrDeath72  路  4Comments