I have a few lines of code to generate a plain image with some given text in php. But when I give width for image text goes outside the image. How can I align text inside the image with a fixed width but dynamic height? My code is given below.
header ("Content-type: image/png");
$string = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s';
$font = 4;
$width = ImageFontWidth($font) * strlen($string);
$height = ImageFontHeight($font);
$im = @imagecreate (200,500);
$background_color = imagecolorallocate ($im, 255, 255, 255); //white background
$text_color = imagecolorallocate ($im, 0, 0,0);//black text
imagestring ($im, $font, 0, 0, $string, $text_color);
imagepng ($im);
I want this image to automatically adjust texts based on given paragraph. How to do that?