title: Text out of the box for converting into image in php
body: <p>I am trying to convert text into image. I already did it, but the are some cases when text is out of the image box<a href="https://i.stack.imgur.com/u3T91.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u3T91.png" alt="Image"></a></p>
  
  <p>The "e" of the word "The" is cut. I have tried decreasing the font size or increasing the width of the image, but in some cases this happen again with another text. This is the code:</p>
  
  <pre><code>    $new_line_position = 61;        
      $angle = 0;        
      $left = 20;
      $top = 45;
      $image_width = 1210;
      $image_line_height = 45;                
  
      $content_input = wordwrap($content_input,    $new_line_position, "\n", true);  
  
      $lineas = preg_split('/\\n/', $content_input);
      $lines_breaks = count($lineas); 
      $image_height = $image_line_height * $lines_breaks;
      $im = imagecreatetruecolor($image_width, $image_height);
  
      // Create some colors
      $white = imagecolorallocate($im, 255, 255, 255);        
      $black = imagecolorallocate($im, 0, 0, 0);
      imagefilledrectangle($im, 0, 0, $image_width, $image_height, $white);   
  
     $font_ttf =  public_path().'/fonts/'.$ttf_font;                     
  
  
      foreach($lineas as $linea){
          imagettftext($im, $font_size, $angle, $left, $top, $black, $font_ttf, $linea);        
          $top = $top + $image_line_height;
      }
  
      // Add the text                        
      imagepng($im);                
      imagedestroy($im);
  </code></pre>
  
  <p>Thank you.</p>