PHPImage

Samples Summary
Samples sample1
Ecriture d'un script "simple"
require(__DIR__.'/../../src/class.PHPImage.php');
$image = new PHPImage();
$image->fontfile = '../methods/verdana.ttf';
$text      = "The really true\nsolution is : 42 ...";
$forecolor = 'red';
$bgcolor   = 'lightblue';
$corner    = 'round';
$fontsize  = 14;
list($w, $h) = $image->gettextbox($text, $fontsize);
if ($w > $h) {
	$margin = round(0.30*$h);
} else {
	$margin = round(0.30*$w);
}
$w += 2*$margin;
$h += 2*$margin;
$image->create($w, $h);
$image->drawrectanglewh(0, 0, $w, $h, $forecolor, 1, 'solid', 'all('.$corner.', '.$margin.')');
$image->fill($w/2, $h/2, $bgcolor);
$image->writetext('50%', '50%', $text, $fontsize, 0, $forecolor, 'center', 'center');
$image->format = 'png';
$image->display();

sample2
Même script avec héritage de classe (meilleur)
require(__DIR__.'/../../src/class.PHPImage.php');

class MyClass extends PHPImage {
	function makeframe($text, $forecolor, $bgcolor, $corner, $fontsize) {
		list($w, $h) = $this->gettextbox($text, $fontsize);
		if ($w > $h) {
			$margin = round(0.30*$h);
		} else {
			$margin = round(0.30*$w);
		}
		$w += 2*$margin;
		$h += 2*$margin;
		$this->create($w, $h);
		$this->drawrectanglewh(0, 0, $w, $h, $forecolor, 1, 'solid', 'all('.$corner.', '.$margin.')');
		$this->fill($w/2, $h/2, $bgcolor);
		$this->writetext('50%', '50%', $text, $fontsize, 0, $forecolor, 'center', 'center');
	}
}

$image = new MyClass();
$image->fontfile = '../methods/verdana.ttf';
$image->makeframe("The really true\nsolution is : 42 ...", 'gold', 'black', 'curve', 14);
$image->format = 'png';
$image->display();