Codeigniter library to solve Persian problem with GD
This library helps you to use Persian characters with GD in codeignietr 4.x
- Download the source files
- Copy the folder
Libraries
toapp
folder of your CodeIgniter installation - That's it! Start using with the examples below
Let's get started :) First, we will load the PersianGD Library into the system
use App\Libraries\PersianGD;
That was easy!
Now let's create object of PersianGD
$gd = new PersianGD();
OK, now we can get text ready to use with gd
$str = 'سلام امیر';
$tx = $gd->convert_to_persian($str);
You have reached the end of the Quick Start Guide, but please take a look at the Example code section
<?php
namespace App\Controllers;
use Config\Services;
use App\Libraries\PersianGD;
class Home extends BaseController
{
public function index()
{
$str = 'سلام امیر';
$gd = new PersianGD();
$tx = $gd->convert_to_persian($str);
$image = Services::image('gd')
->withFile(WRITEPATH . 'uploads/image/mypic.jpg')
->text($tx, [
'color' => '#fff',
'opacity' => 0,
'withShadow' => false,
'hAlign' => 'center',
'vAlign' => 'bottom',
'fontPath' => APPPATH . 'Fonts/BRoya.ttf',
'fontSize' => 20
])
->save(WRITEPATH . 'uploads/image/img.jpg');
return view('welcome_message');
}
}