これが私がこれまで持っているクラスです:
<?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());
}
}
?>
誰でも何か考えがありますか?遅いのか分からないのか、なぜかこの文章を書いていると頭が真っ白になります。
最初のように属性を書き込めるようにしたい
$gd = new gd;
$gd->fontsize('12');
//..etc
次に、実際の出力は次のように記述されます
$gd->display('this is my string','myfont.ttf');