tags:

views:

56

answers:

2

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 its late or i dont know, for some reason i feel blank when writing this one.

i want to be able to write the attribs 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');

A: 

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 :)

lfx
thanks but do you think it would be possible once i get this thing working? like say if i have a few tabs and for each tab run the function from the class and output a custom font string?
SarmenHB
Yea, why not? Each tab is new session to web server so new copy of your 'stuff'. And if you want to have many img's you should init that class whit new name $one = new txt2img(); $two = new txt2img() it this way you get different objects.
lfx
A: 
  1. Get an IDE with SyntaxHighlighting
  2. Learn PHP5 OOP Basics
  3. Read the error messages

You have a wild mix of $this->img, $this->image, $this->img() and $image there ...

Philippe Gerber