PHP Classes

File: img.php

Recommend this page to a friend!
  Classes of Taslim Mazumder Sohel  >  Align and justify text in image  >  img.php  >  Download  
File: img.php
Role: Example script
Content type: text/plain
Description: Example File
Class: Align and justify text in image
Create image with aligned text
Author: By
Last change:
Date: 9 years ago
Size: 1,051 bytes


Class file image Download
 * If it show "Fatal error: Call to undefined function: imagecreate()" then
 * you have to install GD. To know detail about GD
 * see that documentation :



$_im = new TextToImage();

$str = "New life in programming.\nNext Line of Image.\nLine Number 3\n" .
"This is line numbet 4\nLine number 5\nYou can write as you want.";

//kip the CENTURY.TTF file in same folder. Default justification is Center.
$_im->imagettfJustifytext($str,"CENTURY.TTF"); //

//$_im->imagettfJustifytext($str,"CENTURY.TTF", 0); //Justify text to left.
//$_im->imagettfJustifytext($str,"CENTURY.TTF", 1); //Justify text to right.
//$_im->imagettfJustifytext($str,"CENTURY.TTF", 2); //Justify text to center.

//$_im->showAsJpg(); //Show picture as jpg.
//$_im->showAsPng(); //Show picture as png.
//$_im->saveAsPng("Image1"); //Save picture as png.

$_im->showAsGif(); //Show picture as gif.