示例#1
0
function imagettfstroke(&$image, $size, $angle, $left, $right, $top, $bottom, $color, $font, $text, $max_width)
{
    imagettftextbox($image, $size, $angle, $left, $top, $color, $font, $text, $max_width);
    imagettftextbox($image, $size, $angle, $right, $top, $color, $font, $text, $max_width);
    imagettftextbox($image, $size, $angle, $left, $bottom, $color, $font, $text, $max_width);
    imagettftextbox($image, $size, $angle, $right, $bottom, $color, $font, $text, $max_width);
}
示例#2
0
$text_str = $_GET['text'] ? base64_decode($_GET['text']) : 'TITLE NOT MENTIONED';
$text_size = $_GET['size'] ? $_GET['size'] : 10;
// Define the variables
$textImg_font = "eict.ttf";
$textImg_width = imageWidth($text_size, strlen($text_str));
$textImg_height = imageHeight($text_size);
// Set Co-ordinates
$bluetext_bottom = floor($textImg_height - $text_size / 2);
//Create Image of size $textImg_length x $textImg_height
$background = imagecreatetruecolor($textImg_width, $textImg_height);
// Colors Used in the image
$text_fontcolor = imagecolorallocate($background, 4, 75, 162);
$text_shadowcolor = imagecolorallocate($background, 140, 140, 140);
$text_strokecolor = imagecolorallocate($background, 255, 255, 255);
//Make it transparent
imagesavealpha($background, true);
$trans_colour = imagecolorallocatealpha($background, 0, 0, 0, 127);
imagefill($background, 0, 0, $trans_colour);
// STRIP THE SLASHES IN THE TEXT
$text_str = stripslashes($text_str);
// FIRST PRINT THE SHADOW ON THE TRANSPARENT IMAGE
imagettftextbox($background, $text_size, 0, -5, $bluetext_bottom + 4, $text_shadowcolor, $textImg_font, $text_str, $textImg_width);
// NOW GIVE WHITE STROKE THAT WILL BE SEEN AROUNT THE BLUE TEXT
imagettfstroke($background, $text_size, 0, -3, 3, $bluetext_bottom - 2, $bluetext_bottom + 2, $text_shadowcolor, $textImg_font, $text_str, $textImg_width);
imagettfstroke($background, $text_size, 0, -3, 3, $bluetext_bottom - 2, $bluetext_bottom + 2, $text_strokecolor, $textImg_font, $text_str, $textImg_width);
// WRITE THE TEXT IN BLUE
imagettftextbox($background, $text_size, 0, 0, $bluetext_bottom, $text_fontcolor, $textImg_font, $text_str, $textImg_width);
//Create image
imagepng($background);
//destroy image
imagedestroy($background);
示例#3
0
文件: generate.php 项目: palmic/lbox
     }
     gd_alpha();
     imagefilledrectangle($image, 0, 0, imagesx($image), imagesy($image), gd_bkg());
     render_text($bounds);
     break;
 case 'wrap':
     if (!is_number($FStyle['cLine'], true)) {
         $FStyle['cLine'] = 1.0;
     }
     $bounds = bounding_box($FLIR['text']);
     if ($FStyle['realFontHeight'] != 'true') {
         $REAL_HEIGHT_BOUNDS = $bounds;
     }
     // if mode is wrap, check to see if text needs to be wrapped, otherwise let continue to progressive
     if ($bounds['width'] > $FLIR['maxwidth']) {
         $image = imagettftextbox($FLIR['size_pts'], 0, 0, 0, $FLIR['color'], $FLIR['font'], $FLIR['text'], $FLIR['maxwidth'], strtolower($FStyle['cAlign']), $FStyle['cLine']);
         break;
     } else {
         if (false === @($image = imagecreatetruecolor($bounds['width'], $REAL_HEIGHT_BOUNDS['height']))) {
             err('COULD_NOT_CREATE');
         }
         gd_alpha();
         imagefilledrectangle($image, 0, 0, imagesx($image), imagesy($image), gd_bkg());
         render_text($bounds);
     }
     break;
 case 'progressive':
     $bounds = bounding_box($FLIR['text']);
     if ($FStyle['realFontHeight'] != 'true') {
         $REAL_HEIGHT_BOUNDS = $bounds;
     }
     gd_alpha();
     imagefilledrectangle($image, 0, 0, imagesx($image), imagesy($image), gd_bkg());
     imagettftext($image, $FLIR['size_pts'], 0, $bounds['xOffset'], $REAL_HEIGHT_BOUNDS['yOffset'], gd_color($image), $FLIR['font'], $FLIR['text']);
     break;
 case 'wrap':
     //		is_number($str, $bAllowDecimals=false, $bAllowZero=false, $bAllowNeg=false)
     if (!is_number($CSS['line-height'], true, true, true)) {
         $CSS['line-height'] = 1.0;
     }
     $bounds = bounding_box($FLIR['text']);
     if ($FStyle['fixBaseline'] != 'true') {
         $REAL_HEIGHT_BOUNDS = $bounds;
     }
     // if mode is wrap, check to see if text needs to be wrapped, otherwise let continue to progressive
     if ($bounds['width'] > $FLIR['maxwidth']) {
         $image = imagettftextbox($FLIR['size_pts'], 0, 0, 0, $FLIR['color'], $FLIR['font'], $FLIR['text'], $FLIR['maxwidth'], strtolower($CSS['text-align']), $CSS['line-height']);
         if (false !== $image) {
             // if cannot wrap, don't break and continue on to next mode
             break;
         }
     }
 case 'progressive':
     $bounds = bounding_box($FLIR['text']);
     if ($FStyle['fixBaseline'] != 'true') {
         $REAL_HEIGHT_BOUNDS = $bounds;
     }
     $offset_left = 0;
     $nsize = $FLIR['size_pts'];
     while (($REAL_HEIGHT_BOUNDS['height'] > $FLIR['maxheight'] || $bounds['width'] > $FLIR['maxwidth']) && $nsize > 2) {
         $nsize -= 0.5;
         $bounds = bounding_box($FLIR['text'], NULL, $nsize);