÷åã:
<?php
// Set the content-type
header("Content-type: image/png");
$text=$_GET['text'];
$color=$_GET['color'];
$font=$_GET['font'];
$size=$_GET['size'];
$stringArrt=split(';',$text);
$tmp="&#";
$stringforinput="";
//support multiline
for ( $counter = 0; $counter < sizeof($stringArrt); $counter += 1) {
if ( $stringArrt[$counter] == 13) {
$stringforinput=$stringforinput."\n";
} else {
$tmp1=$tmp.$stringArrt[$counter].';';
$stringforinput=$stringforinput.$tmp1;
}
}
//check for text size
$check=imagettfbbox( $size, 0, getcwd()."/fonts/".$font, $stringforinput);
$width=$check[2]-$check[0];
$height=$check[3]-$check[5];
$im = imagecreatetruecolor($width+5,$height*2+10);
$transparent = imageColorAllocate($im, 255, 255, 255);
imageColorTransparent($im, $transparent);
imagefilledrectangle($im, 0, 0, $width-1+5, $height*2+10, $transparent);
// Add the text
imagettftext($im, $size, 0, 0,$height, $color, "fonts/".$font, $stringforinput);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>