Skip to content

Instantly share code, notes, and snippets.

@AbiruzzamanMolla
Forked from nazmulpcc/render-bangla-text.php
Created October 25, 2016 06:37
Show Gist options
  • Save AbiruzzamanMolla/5827a25e9f839251b76a62fff7d2cca7 to your computer and use it in GitHub Desktop.
Save AbiruzzamanMolla/5827a25e9f839251b76a62fff7d2cca7 to your computer and use it in GitHub Desktop.
<?php
require 'Unicode2Bijoy.php'; // https://github.com/mirazmac/Unicode2Bijoy
use mirazmac\Unicode2Bijoy;
$str = Unicode2Bijoy::convert("যুক্তাক্ষর প্রিন্ট করা \n খুবই সোজা"); //convert the text
$im = imagecreatetruecolor(300, 300); //create the image
$bg = imagecolorallocate($im, 255, 255, 255); //allocating white background image
$color = imagecolorallocate($im, 0, 0, 255); //color of the text
imagefill($im, 0, 0, $bg);
$fontfile = 'kalpurushANSI.ttf'; //ansi font file
imagettftext ($im , 20 , 0 , 20 , 30 , $color , $fontfile , $str); //write the text on image, you need to have ImageMagick installed
header('Content-type: image/png');
imagepng($im); //output
imagedestroy($im); //free memory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment