gd - How to create an image in php with justified text -


i want create image contains text letter spacing adapted text stretch within given space. goal split text in lines of max x millimeters , justify (increase letter spacing) text.

here example of current output:

enter image description here

this how should look:

enter image description here

here current code:

function imagestringwrap($image, $font, $x, $y, $text, $color, $maxwidth, $textcolor) {     $fontwidth = imagefontwidth($font);     $fontheight = imagefontheight($font);      if ($maxwidth != null) {         $maxcharsperline = floor($maxwidth / $fontwidth);         $text = wordwrap($text, $maxcharsperline, "\n", 1);       }      $lines = explode("\n", $text);     while (list($numl, $line) = each($lines)) {         $fontfile = imageloadfont('app_global/ttf/verdana.ttf');         imagestring($image, 14, $x, $y, $line, $color);         #imagettftext ($image, 14 , 0, $x , $y , $color , $fontfile ,  $line );         $y += $fontheight;       }      $hight = 20*count($lines);     imageline ($image , 10 , 5 , 290, 5 , $textcolor );     imageline ($image , 10 , $hight , 290, $hight , $textcolor ); }   header("content-type: image/png"); $string = urldecode($_get['text']); $im     = imagecreate(300, 150);  // white background , blue text $bg = imagecolorallocate($im, 255, 255, 255); $textcolor = imagecolorallocate($im, 0, 0, 0);    #imageline ($im , 0 , 10 , 200, 0 , $textcolor ); // write string @ top left #imagestring($im, 11, 10, 10, $string, $textcolor); imagestringwrap($im, 11, 10, 10, $string, $textcolor, imagesx($im), $textcolor); 

how achieve php?

with code php.net site mentioned inside comment section pretty close, text appears blurry:

enter image description here


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -