当前位置: 首页>>代码示例>>PHP>>正文


PHP ImageFontHeight函数代码示例

本文整理汇总了PHP中ImageFontHeight函数的典型用法代码示例。如果您正苦于以下问题:PHP ImageFontHeight函数的具体用法?PHP ImageFontHeight怎么用?PHP ImageFontHeight使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ImageFontHeight函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ConvertToImage

function ConvertToImage($content)
{
    $imageFile = ".counter.png";
    $relativePath = ".counter.png";
    $noOfChars = strlen($content);
    $charHeight = ImageFontHeight(5);
    $charWidth = ImageFontWidth(5);
    $strWidth = $charWidth * $noOfChars;
    $strHeight = $charHeight;
    //15 padding
    $imgWidth = $strWidth + 15;
    $imgHeight = $strHeight + 15;
    $imgCenterX = $imgWidth / 2;
    $imgCenterY = $imgHeight / 2;
    $im = ImageCreate($imgWidth, $imgHeight);
    $script = ImageColorAllocate($im, 0, 255, 0);
    $outercolor = ImageColorAllocate($im, 99, 140, 214);
    $innercolor = ImageColorAllocate($im, 0, 0, 0);
    ImageFilledRectangle($im, 0, 0, $imgWidth, $imgHeight, $outercolor);
    ImageFilledRectangle($im, 3, 3, $imgWidth - 4, $imgHeight - 4, $innercolor);
    //draw string
    $drawPosX = $imgCenterX - $strWidth / 2 + 1;
    $drawPosY = $imgCenterY - $strHeight / 2;
    ImageString($im, 5, $drawPosX, $drawPosY, $content, $script);
    //save image and return
    ImagePNG($im, $imageFile);
    return $relativePath;
}
开发者ID:sahil2441,项目名称:Prolog-Problems,代码行数:28,代码来源:counter.php

示例2: gd_button

 function gd_button()
 {
     if (file_exists($this->save_dir . $this->filename)) {
         return $this->filename;
     }
     $this->font_size = 5;
     $text_width = ImageFontWidth($this->font_size) * strlen($this->font_text);
     $text_height = ImageFontHeight($this->font_size);
     $this->width = $this->xspace * 2 + $text_width;
     $this->height = $this->yspace + $text_height;
     $this->xpos = $this->width / 2 - $text_width / 2;
     if ($this->xpos < 0) {
         $this->xpos = $this->xspace;
     }
     $this->ypos = $this->height / 2 - $text_height / 2;
     if ($this->ypos < 0) {
         $this->ypos = $this->yspace;
     }
     $this->button_init();
     $black = ImageColorAllocate($this->image, 0, 0, 0);
     ImageRectangle($this->image, 0, 0, $this->width - 1, $this->height - 1, $black);
     $white = ImageColorAllocate($this->image, 255, 255, 255);
     ImageRectangle($this->image, 0, 0, $this->width, $this->height, $white);
     ImageString($this->image, $this->font_size, intval($this->xpos + 1), intval($this->ypos), $this->font_text, $black);
     ImageString($this->image, $this->font_size, intval($this->xpos), intval($this->ypos - 1), $this->font_text, $white);
     return $this->save_button();
 }
开发者ID:HaakonME,项目名称:porticoestate,代码行数:27,代码来源:class.gdbutton.inc.php

示例3: generateImage

 function generateImage($token)
 {
     $iFont = 5;
     // Font ID
     $iSpacing = 2;
     // Spacing between characters
     $iDisplacement = 5;
     // Vertical chracter displacement
     // Establish font metric and image size
     $iCharWidth = ImageFontWidth($iFont);
     $iCharHeight = ImageFontHeight($iFont);
     $iWidth = strlen($token) * ($iCharWidth + $iSpacing);
     $iHeight = $iCharHeight + 2 * $iDisplacement;
     // Create the image
     $pic = ImageCreate($iWidth, $iHeight);
     // Allocate a background and foreground colour
     $col = array('white' => ImageColorAllocate($pic, 255, 255, 255), 'blue' => ImageColorAllocate($pic, 45, 45, 100), 'green' => ImageColorAllocate($pic, 45, 100, 45), 'red' => ImageColorAllocate($pic, 100, 45, 45), 'purple' => ImageColorAllocate($pic, 100, 45, 100), 'grey' => ImageColorAllocate($pic, 225, 225, 225), 'grey2' => ImageColorAllocate($pic, 200, 200, 200));
     for ($x = 0; $x < $iWidth; $x += 2) {
         for ($y = 0; $y < $iHeight; $y += 2) {
             ImageSetPixel($pic, $x, $y, $col['grey']);
         }
     }
     $iX = 1;
     for ($i = 0; $i < strlen($token); $i++) {
         ImageChar($pic, $iFont - 1, $iX, $iDisplacement - rand(-$iDisplacement, $iDisplacement), $token[$i], $col['grey2']);
         $iX += $iCharWidth + $iSpacing;
     }
     $iX = 2;
     $c = array('blue', 'green', 'red', 'purple');
     for ($i = 0; $i < strlen($token); $i++) {
         $colour = $c[rand(0, count($c) - 1)];
         ImageChar($pic, $iFont, $iX, $iDisplacement - rand(-$iDisplacement, $iDisplacement), $token[$i], $col[$colour]);
         $iX += $iCharWidth + $iSpacing;
     }
     for ($x = 1; $x < $iWidth; $x += 4) {
         for ($y = 1; $y < $iHeight; $y += 4) {
             ImageSetPixel($pic, $x, $y, $col['white']);
         }
     }
     // Draw some lines
     for ($i = 0; $i < 4; $i++) {
         ImageLine($pic, rand(0, $iWidth / 2), rand(0, $iHeight / 2), rand($iWidth / 2, $iWidth), rand($iHeight / 2, $iHeight), $col['white']);
     }
     ob_start();
     if (function_exists('imagejpeg')) {
         ImageJPEG($pic);
     } elseif (function_exists('imagepng')) {
         ImagePNG($pic);
     } else {
         ob_end_clean();
         return false;
     }
     $data = ob_get_contents();
     ob_end_clean();
     ImageDestroy($pic);
     return $data;
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:57,代码来源:Turing.php

示例4: image_create

function image_create($image, $size, $x, $y, $text, $color, $maxwidth)
{
    $fontwidth = ImageFontWidth($size);
    $fontheight = ImageFontHeight($size);
    if ($maxwidth != NULL) {
        $maxchar = floor($maxwidth / $fontwidth);
        $text = wordwrap($text, $maxchar, "\n", 1);
    }
    $lines = explode("\n", $text);
    while (list($numl, $line) = each($lines)) {
        ImageString($image, $size, $x, $y, $line, $color);
        $y += $fontheight;
    }
}
开发者ID:planktonicme,项目名称:phproxyimproved,代码行数:14,代码来源:image.php

示例5: render_png

 function render_png($string, $hash)
 {
     $font = 4;
     $width = ImageFontWidth($font) * strlen($string);
     $height = ImageFontHeight($font);
     $im = @imagecreate($width, $height);
     $background_color = imagecolorallocate($im, 255, 255, 255);
     //white background
     $text_color = imagecolorallocate($im, 0, 0, 0);
     //black text
     imagecolortransparent($im, $background_color);
     imagestring($im, $font, 0, 0, $string, $text_color);
     $pngdata = imagepng($im, $this->CACHE_DIR . "/{$hash}.png");
     chdir($current_dir);
 }
开发者ID:ksb1712,项目名称:pragyan,代码行数:15,代码来源:pngRender.class.php

示例6: fatal_error

function fatal_error($message)
{
    // send an image
    if (function_exists('ImageCreate')) {
        $width = ImageFontWidth(5) * strlen($message) + 10;
        $height = ImageFontHeight(5) + 10;
        if ($image = ImageCreate($width, $height)) {
            $background = ImageColorAllocate($image, 255, 255, 255);
            $text_color = ImageColorAllocate($image, 0, 0, 0);
            ImageString($image, 5, 5, 5, $message, $text_color);
            header('Content-type: image/png');
            ImagePNG($image);
            ImageDestroy($image);
            exit;
        }
    }
    // send 500 code
    header("HTTP/1.0 500 Internal Server Error");
    print $message;
    exit;
}
开发者ID:Newsoft-Computer,项目名称:CLI0005-IVAO-Colombia,代码行数:21,代码来源:weatherstatus.php

示例7: createImage

function createImage($text, $width, $height, $font = 5)
{
    global $fontColor, $bgColor, $lineColor;
    if ($img = @ImageCreate($width, $height)) {
        list($R, $G, $B) = convertRGB($fontColor);
        $fontColor = ImageColorAllocate($img, $R, $G, $B);
        list($R, $G, $B) = convertRGB($bgColor);
        $bgColor = ImageColorAllocate($img, $R, $G, $B);
        list($R, $G, $B) = convertRGB($lineColor);
        $lineColor = ImageColorAllocate($img, $R, $G, $B);
        ImageFill($img, 0, 0, $bgColor);
        for ($i = 0; $i <= $width; $i += 5) {
            @ImageLine($img, $i, 0, $i, $height, $lineColor);
        }
        for ($i = 0; $i <= $height; $i += 5) {
            @ImageLine($img, 0, $i, $width, $i, $lineColor);
        }
        $hcenter = $width / 2;
        $vcenter = $height / 2;
        $x = round($hcenter - ImageFontWidth($font) * strlen($text) / 2);
        $y = round($vcenter - ImageFontHeight($font) / 2);
        ImageString($img, $font, $x, $y, $text, $fontColor);
        if (function_exists('ImagePNG')) {
            header('Content-Type: image/png');
            @ImagePNG($img);
        } else {
            if (function_exists('ImageGIF')) {
                header('Content-Type: image/gif');
                @ImageGIF($img);
            } else {
                if (function_exists('ImageJPEG')) {
                    header('Content-Type: image/jpeg');
                    @ImageJPEG($img);
                }
            }
        }
        ImageDestroy($img);
    }
}
开发者ID:ghahremany,项目名称:creat-TAG,代码行数:39,代码来源:image.php

示例8: ts_gfx

function ts_gfx($ts_random)
{
    global $site_key;
    $datekey = date("F j");
    $rcode = hexdec(md5($_SERVER[HTTP_USER_AGENT] . $sitekey . $ts_random . $datekey));
    $code = substr($rcode, 2, 6);
    $circles = 5;
    $lines = 1;
    $width = 100;
    $height = 40;
    $font = 5;
    $fontwidth = ImageFontWidth($font) * strlen($string);
    $fontheight = ImageFontHeight($font);
    $im = @imagecreate($width, $height);
    $background_color = imagecolorallocate($im, 255, 138, 0);
    $text_color = imagecolorallocate($im, rand(200, 255), rand(200, 255), rand(200, 255));
    // Random Text
    #rgb(1%, 51%, 87%)
    $r = 0.87;
    $g = 0.51;
    $b = 0.0;
    for ($i = 1; $i <= $circles; $i++) {
        $value = rand(200, 255);
        $randomcolor = imagecolorallocate($im, $value * $r, $value * $g, $value * $b);
        imagefilledellipse($im, rand(0, $width - 20), rand(0, $height - 6), rand(15, 70), rand(15, 70), $randomcolor);
    }
    imagerectangle($im, 0, 0, $width - 1, $height - 1, $text_color);
    imagestring($im, $font, 22, 12, $code, $text_color);
    for ($i = 0; $i < $lines; $i++) {
        $y1 = rand(14, 23);
        $y2 = rand(15, 24);
        $randomcolor = imagecolorallocate($im, rand(100, 255), 0, rand(100, 255));
        imageline($im, 0, $y1, $width, $y2, $randomcolor);
    }
    header("Content-type: image/jpeg");
    imagejpeg($im, '', 85);
    ImageDestroy($im);
    die;
}
开发者ID:holsinger,项目名称:openfloor,代码行数:39,代码来源:ts.php

示例9: print_image

 function print_image($text)
 {
     $w = 50;
     $image = imagecreate($w, 25);
     $light = ImageColorAllocate($image, 255, 255, 0);
     $dark = ImageColorAllocate($image, 0, 0, 0);
     $gray = ImageColorAllocate($image, 0, 0, 0);
     ImageFill($image, 0, 0, $light);
     $width_two = ImageFontWidth(5) * strlen($text);
     $height = ImageFontHeight(100);
     $width = ($w - $width_two) / 2;
     # vertical lines
     for ($x = 0; $x <= 100; $x += 10) {
         ImageLine($image, $x, 0, $x, 100, $dark);
     }
     # horizontal lines
     for ($x = 0; $x <= 100; $x += 10) {
         ImageLine($image, 0, $x, 100, $x, $dark);
     }
     ImageString($image, 5, $width, 4, $text, $dark);
     ImagePNG($image, '', 80);
     ImageDestroy($image);
 }
开发者ID:BackupTheBerlios,项目名称:yac-svn,代码行数:23,代码来源:images_class.php

示例10: textHeight

 /**
  * Get the height of a text.
  * 
  * Note! This method can give some peculiar results, since ImageTTFBBox() returns the total
  * bounding box of a text, where ImageTTF() writes the text on the baseline of the text, that
  * is 'g', 'p', 'q' and other letters that dig under the baseline will appear to have a larger
  * height than they actually do. Have a look at the tests/text.php test case - the first two
  * columns, 'left and 'center', both look alright, whereas the last column, 'right', appear
  * with a larger space between the first text and the second. This is because the total height
  * is actually smaller by exactly the number of pixels that the 'g' digs under the baseline.
  * Remove the 'g' from the text and they appear correct. 
  *
  * @param string $text The text to get the height of
  * @param bool $force Force the method to calculate the size
  * @return int The height of the text
  */
 function textHeight($text, $force = false)
 {
     if (isset($this->_font['file'])) {
         $angle = 0;
         if (isset($this->_font['angle'])) {
             $angle = $this->_font['angle'];
         }
         $linebreaks = substr_count($text, "\n");
         if ($angle == 0 && $force === false) {
             /*
              * if the angle is 0 simply return the size, due to different
              * heights for example for x-axis labels, making the labels
              * _not_ appear as written on the same baseline
              */
             return $this->_font['size'] + ($this->_font['size'] + 2) * $linebreaks;
         }
         $height = 0;
         $lines = explode("\n", $text);
         foreach ($lines as $line) {
             $bounds = ImageTTFBBox($this->_font['size'], $angle, $this->_font['file'], $line);
             $y0 = min($bounds[1], $bounds[3], $bounds[5], $bounds[7]);
             $y1 = max($bounds[1], $bounds[3], $bounds[5], $bounds[7]);
             $height += abs($y0 - $y1);
         }
         return $height + $linebreaks * 2;
     } else {
         if (isset($this->_font['vertical']) && $this->_font['vertical']) {
             $width = 0;
             $lines = explode("\n", $text);
             foreach ($lines as $line) {
                 $width = max($width, ImageFontWidth($this->_font['font']) * strlen($line));
             }
             return $width;
         } else {
             return ImageFontHeight($this->_font['font']) * (substr_count($text, "\n") + 1);
         }
     }
 }
开发者ID:chiranjeevjain,项目名称:agilebill,代码行数:54,代码来源:GD.php

示例11: createCaptchaBackground

 function createCaptchaBackground()
 {
     // Breite eines Zeichens
     $this->image_font_width = ImageFontWidth($this->font_type) + 2;
     // Hoehe eines Zeichens
     $this->image_font_height = ImageFontHeight($this->font_type) + 2;
     // Zufallswerte für hintergrundfarbe
     if ($this->useRandomColors) {
         $this->setBgColor(intval(rand(225, 255)), intval(rand(225, 255)), intval(rand(225, 255)));
     } else {
         $this->setBgColor(225, 225, 225);
     }
     // Hintergrund-Farbe stzen
     $captcha_background_color = ImageColorAllocate($this->image, $this->bgColor['r'], $this->bgColor['g'], $this->bgColor['b']);
     // Flaeche fuellen
     ImageFilledRectangle($this->image, 0, 0, $this->width, $this->height, $captcha_background_color);
     // Zufallsstrings durchloopen
     for ($x = 0; $x < $this->background_intensity; $x++) {
         // Zufallsstring-Farbe
         $random_string_color = ImageColorAllocate($this->image, intval(rand(164, 254)), intval(rand(164, 254)), intval(rand(164, 254)));
         // Zufalls-String generieren
         $random_string = chr(intval(rand(65, 122)));
         // X-Position
         $x_position = intval(rand(0, $this->width - $this->image_font_width * strlen($random_string)));
         // Y-Position
         $y_position = intval(rand(0, $this->height - $this->image_font_height));
         // Zufalls-String
         ImageString($this->image, $this->font_type, $x_position, $y_position, $random_string, $random_string_color);
     }
     if ($this->addagrid) {
         $this->addGrid();
     }
     if ($this->addhorizontallines) {
         $this->addHorizontalLines();
     }
 }
开发者ID:kveldscholten,项目名称:Ilch-1.1,代码行数:36,代码来源:Captcha.php

示例12: define

** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
define('ZBX_PAGE_NO_AUTHERIZATION', 1);
require_once "include/config.inc.php";
$page['file'] = 'vtext.php';
$page['type'] = PAGE_TYPE_IMAGE;
include_once "include/page_header.php";
//		VAR			TYPE	OPTIONAL FLAGS	VALIDATION	EXCEPTION
$fields = array("text" => array(T_ZBX_STR, O_OPT, P_SYS, null, null), "font" => array(T_ZBX_INT, O_OPT, null, BETWEEN(1, 5), null));
check_fields($fields);
$text = get_request("text", ' ');
$font = get_request("font", 3);
$width = ImageFontWidth($font) * strlen($text);
$height = ImageFontHeight($font);
$im = imagecreate($height, $width);
$backgroud_color = ImageColorAllocate($im, 255, 255, 255);
$text_color = ImageColorAllocate($im, 0, 0, 0);
ImageStringUp($im, $font, 0, $width - 1, $text, $text_color);
imagecolortransparent($im, $backgroud_color);
ImageOut($im);
ImageDestroy($im);
include_once "include/page_footer.php";
开发者ID:phedders,项目名称:zabbix,代码行数:31,代码来源:vtext.php

示例13: process


//.........这里部分代码省略.........
                         $this->error = _("Watermark image is of unknown type");
                     }
                 }
                 // add text
                 if (!empty($this->image_text)) {
                     $this->log .= '- ' . _("add text") . '<br />';
                     if (!is_numeric($this->image_text_padding)) {
                         $this->image_text_padding = 0;
                     }
                     if (!is_numeric($this->image_text_line_spacing)) {
                         $this->image_text_line_spacing = 0;
                     }
                     if (!is_numeric($this->image_text_padding_x)) {
                         $this->image_text_padding_x = $this->image_text_padding;
                     }
                     if (!is_numeric($this->image_text_padding_y)) {
                         $this->image_text_padding_y = $this->image_text_padding;
                     }
                     $this->image_text_position = strtolower($this->image_text_position);
                     $this->image_text_direction = strtolower($this->image_text_direction);
                     $this->image_text_alignment = strtolower($this->image_text_alignment);
                     // if the font is a string, we assume that we might want to load a font
                     if (!is_numeric($this->image_text_font) && strlen($this->image_text_font) > 4 && substr(strtolower($this->image_text_font), -4) == '.gdf') {
                         $this->log .= '&nbsp;&nbsp;&nbsp;&nbsp;' . _("try to load font") . ' ' . $this->image_text_font . '... ';
                         if ($this->image_text_font = @imageloadfont($this->image_text_font)) {
                             $this->log .= _("success") . '<br />';
                         } else {
                             $this->log .= _("error") . '<br />';
                             $this->image_text_font = 5;
                         }
                     }
                     $text = explode("\n", $this->image_text);
                     $char_width = ImageFontWidth($this->image_text_font);
                     $char_height = ImageFontHeight($this->image_text_font);
                     $text_height = 0;
                     $text_width = 0;
                     $line_height = 0;
                     $line_width = 0;
                     foreach ($text as $k => $v) {
                         if ($this->image_text_direction == 'v') {
                             $h = $char_width * strlen($v);
                             if ($h > $text_height) {
                                 $text_height = $h;
                             }
                             $line_width = $char_height;
                             $text_width += $line_width + ($k < sizeof($text) - 1 ? $this->image_text_line_spacing : 0);
                         } else {
                             $w = $char_width * strlen($v);
                             if ($w > $text_width) {
                                 $text_width = $w;
                             }
                             $line_height = $char_height;
                             $text_height += $line_height + ($k < sizeof($text) - 1 ? $this->image_text_line_spacing : 0);
                         }
                     }
                     $text_width += 2 * $this->image_text_padding_x;
                     $text_height += 2 * $this->image_text_padding_y;
                     $text_x = 0;
                     $text_y = 0;
                     if (is_numeric($this->image_text_x)) {
                         if ($this->image_text_x < 0) {
                             $text_x = $this->image_dst_x - $text_width + $this->image_text_x;
                         } else {
                             $text_x = $this->image_text_x;
                         }
                     } else {
开发者ID:tieulonglanh,项目名称:leminhhoan-01,代码行数:67,代码来源:upload1.php

示例14: height

 /**
  * Get the height of the text specified in pixels
  * @param string $text The text to calc the height for 
  * @return int The height of the text using the specified font 
  */
 function height($text)
 {
     return ImageFontHeight(IMAGE_GRAPH_FONT);
 }
开发者ID:Apeplazas,项目名称:plazadelatecnologia,代码行数:9,代码来源:Font.php

示例15: header

<?php

header('Content-type:image/jpeg');
if (isset($_GET['email'])) {
    $email = $_GET['email'];
} else {
    echo 'No Email Found';
}
$email_length = strlen($email);
$font_size = 4;
$image_height = ImageFontHeight($font_size);
$image_width = ImageFontWidth($font_size) * $email_length;
$image = imagecreate($image_width, $image_height);
imagecolorallocate($image, 255, 255, 255);
$font_color = imagecolorallocate($image, 0, 0, 0);
imagestring($image, $font_size, 0, 0, $email, $font_color);
imagejpeg($image);
开发者ID:Jscott27,项目名称:PHP-Beginners,代码行数:17,代码来源:generate.php


注:本文中的ImageFontHeight函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。