<?php
function ImageColorAllocateHEX($im,$s){
$bg_dec=hexdec($s);
return imagecolorallocate($im,($bg_dec & 0xFF0000) >> 16,($bg_dec & 0x00FF00) >> 8,($bg_dec & 0x0000FF));
}
$size = 30;
$angle = 0;
$fontfile = "/srv/www/htdocs/web2/html/global/fonts/".$font.".TTF";
Header ("Content-type: image/jpeg");
$position = imagettfbbox($size, $angle, $fontfile, $nick);
if($position[0] <= $position[6]){
$min = $position[0];
}else{
$min = $position[6];
}
if($position[2] >= $position[4]){
$max = $position[2];
}else{
$max = $position[4];
}
$x = $max - $min;
if($position[1] <= $position[3]){
$min = $position[1];
}else{
$min = $position[3];
}
if($position[7] >= $position[5]){
$max = $position[7];
}else{
$max = $position[5];
}
$y = $max - $min;
$im = imagecreate ($x, 0-$y);
$black = ImageColorAllocate ($im, 0, 0, 0);
if($an != "1"){
$col = "cc0000";
}
$color = ImageColorAllocateHEX($im,$col);
ImageTTFText ($im, $size, $angle, 0, 0-$y-$min, $color, $fontfile, $nick);
imagejpeg($im, '', 80);
ImageDestroy ($im);
?>