Here is the class I have so far:
<?php
class txt2img {
var $image;
var $headertype;
var $forecolor;
var $fontsize;
var $fontangle;
var $font;
var $string;
//font size
function fontsize($fontsize) {
return $this->fontsize;
}
//forecolor
function forecolor($forecolor) {
return this->imagecolorallocate($this->img(),$this->forecolor);
}
//image file
function img($image) {
return imagecreatefrompng($this->img);
}
function display($string,$font) {
//display all errors
ini_set("display_errors", "1");
error_reporting(E_ALL);
header('content-type: image/png');
$fcolor = $this->forecolor();
imagettftext($this->img(),$this->fontsize(),0,0,$this->forecolor(),$this->font,$this->string);
imagejpg($this->img());
imagedestroy($this->img());
}
}
?>
Anyone have any idea? Either it's late or I don't know, for some reason I feel blank when writing this one.
I want to be able to write the attributes first like
$gd = new gd;
$gd->fontsize('12');
//..etc
then the actual output would be written like this
$gd->display('this is my string','myfont.ttf');
I think this line is not good
imagettftext($this->img(),$this->fontsize(),0,0,$this->forecolor(),$this->font,$this->string);
because you set nulls whit $this->fontsize() and etc.
it shuld be
imagettftext($this->imgage,$this->fontsize,0,0,$this->forecolor,$this->font,$this->string)
I this this helps :)
You have a wild mix of $this->img
, $this->image
, $this->img()
and $image
there ...