Texter helps to write Bangla/English text on image with PHP GD.
OTHER License
Texter helps to write Bangla/English text on image with PHP GD. It also has featurs like align, maintain lineheight, color settings etc.
$texter = new nazmulpcc\Texter;
$image = imagecreate(500, 300);
imagecolorallocate($image, 255, 255, 255);
$texter->startFrom(50, 90)->width(400)->on($image)->align('center')->fontSize(30)->color('333333');
$texter->text('আমার সোনার বাংলা, আমি তোমায় ভালবাসি Lorem ipsum dolor sit amet.....')->write();
It will give you something like this:
You can easily install Texter via composer or you can manually download the package and include them in your code.
composer require nazmulpcc/Texter
Each method is fairly well documented in the source code. A few important methods:
$texter->fontSize('15pt')
or $texter->fontSize('15px')
. If 'pt' or 'px' is absent, the gd default is used. $texter->startFrom(10, 10)
->color(0, 0, 0)
->align('center')
->width(500)
->text('Hellow World')
->write();
Note: Before you write a piece of text, you must at least set the starting points(startFrom), width, and image.
I developed this out of pure frustration that PHP, one of the most widely used coding language doesn't support Bangla because GD can't handle complex fonts. There are room for a lot of improvements which I will try to accomplish gradually. Please contribute if you can.
This project is lincensed under DBAD license.