= 15) { //split string in two, down the middle $half = (int) ( (strlen($text) / 2) ); // cast to int incase str length is odd $left = trim(substr($text, 0, $half)); $right = trim(substr($text, $half)); // Write Text imagettftext($background, 9, 0, 35, 176, $font_color, $font, $left); imagettftext($background, 9, 0, 35, 186, $font_color, $font, $right); } else { // Write Text imagettftext($background, 9, 0, 35, 172, $font_color, $font, $text); } } // Output header and final image header("Content-type: image/png"); header("Content-Disposition: filename=" . $image); imagepng($background); // Destroy the images imagedestroy($background); imagedestroy($overlay); ?>