Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
imagettftext word wrapping an image string
<? php
function imagettfmultilinetext($image, $size, $angle, $x, $y, $color, $fontfile, $text, $spacing=1) {
$lines=explode("\n",$text);
for($i=0; $i< count($lines); $i++) {
$newY=$y+($i * $size * $spacing);
imagettftext($image, $size, $angle, $x, $newY, $color, $fontfile, $lines[$i], $spacing);
}
return null;
}
if(isset($_GET['description'])){
$text = $_GET['description'];
$new_text = wordwrap($text, 20, '\n');
imagettfmultilinetext($im, 18, 0, 10, 90, $white, $font, $new_text);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.