$left - $rleft, "top" => $top - $rtop, "width" => $rright - $rleft + 1, "height" => $rbottom - $rtop + 1 ); } if (!isset($_GET['code'])) die("`code` parameter not set"); if (!isset($_GET['size'])) die("`size` parameter not set"); if (!isset($_GET['color'])) die("`color` parameter not set"); $colorHtml = strtolower($_GET['color']); if (!preg_match('/^[0-9a-f]{6}$/', $colorHtml) == 1) die('Incorrect color code'); $colorR = base_convert(substr($colorHtml, 0, 2), 16, 10); $colorG = base_convert(substr($colorHtml, 2, 2), 16, 10); $colorB = base_convert(substr($colorHtml, 4, 2), 16, 10); $code = intval($_GET['code']); $size = intval($_GET['size']); if ($code < 0 || $code > 65535) die('Incorrect `code` value'); if ($size < $config['minSize']) $size = $config['minSize']; if ($size > $config['maxSize']) $size = $config['maxSize']; $fontFile = dirname(__FILE__).'/icons.ttf'; $text = html_entity_decode('&#' . $code . ';', ENT_COMPAT, 'UTF-8'); $dim = calculateTextBox($size, 0, $fontFile, $text); $width = $dim['width']; $height = $dim['height']; $left = $dim['left']; $top = $dim['top']; $img = @imagecreatetruecolor($width, $height) or die("Cannot Initialize new GD image stream. Check GD library in installed on server and selected font for existence."); imagesavealpha($img, true); $trans_colour = imagecolorallocatealpha($img, 0, 0, 0, 127); imagefill($img, 0, 0, $trans_colour); $color = imagecolorallocate($img, $colorR, $colorG, $colorB); imagettftext($img, $size, 0, $left, $top, $color, $fontFile, $text); header("Content-type: image/png"); imagepng($img); imagedestroy($img); ?>