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


PHP imagePNG函数代码示例

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


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

示例1: drawRating

function drawRating($rating) {
   $width = $_GET['width'];
   $height = $_GET['height'];
   if ($width == 0) {
     $width = 102;
   }
   if ($height == 0) {
     $height = 10;
   }

   $rating = $_GET['rating'];
   $ratingbar = (($rating/100)*$width)-2;

   $image = imagecreate($width,$height);
   //colors
   $back = ImageColorAllocate($image,255,255,255);
   $border = ImageColorAllocate($image,0,0,0);
   $red = ImageColorAllocate($image,255,60,75);
   $fill = ImageColorAllocate($image,44,81,150);

   ImageFilledRectangle($image,0,0,$width-1,$height-1,$back);
   ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$fill);
   ImageRectangle($image,0,0,$width-1,$height-1,$border);
   imagePNG($image);
   imagedestroy($image);
}
开发者ID:jasimmk,项目名称:DeveloperSupport,代码行数:26,代码来源:image.php

示例2: drawRating

function drawRating()
{
    $width = $_GET['width'];
    $height = $_GET['height'];
    if ($width == 0) {
        $width = 200;
    }
    if ($height == 0) {
        $height = 7;
    }
    $rating = $_GET['rating'];
    $ratingbar = $rating / 100 * $width - 2;
    $image = imagecreate($width, $height);
    $fill = ImageColorAllocate($image, 0, 255, 0);
    if ($rating > 49) {
        $fill = ImageColorAllocate($image, 255, 255, 0);
    }
    if ($rating > 74) {
        $fill = ImageColorAllocate($image, 255, 128, 0);
    }
    if ($rating > 89) {
        $fill = ImageColorAllocate($image, 255, 0, 0);
    }
    $back = ImageColorAllocate($image, 205, 205, 205);
    $border = ImageColorAllocate($image, 0, 0, 0);
    ImageFilledRectangle($image, 0, 0, $width - 1, $height - 1, $back);
    ImageFilledRectangle($image, 1, 1, $ratingbar, $height - 1, $fill);
    ImageRectangle($image, 0, 0, $width - 1, $height - 1, $border);
    imagePNG($image);
    imagedestroy($image);
}
开发者ID:SheppeR,项目名称:rapidleech,代码行数:31,代码来源:bar.php

示例3: saveImage

 function saveImage($filename)
 {
     $image =& $this->image;
     if ($this->getStatus()) {
         imagePNG($image, $filename);
     }
 }
开发者ID:kumarsivarajan,项目名称:ctrl-dock,代码行数:7,代码来源:image.class.php

示例4: drawRating

function drawRating($rating)
{
    $width = 300;
    $height = 15;
    $ratingbar = $rating / 100 * $width - 2;
    $image = imagecreate($width, $height);
    $fill = ImageColorAllocate($image, 67, 219, 0);
    if ($rating > 74) {
        $fill = ImageColorAllocate($image, 233, 233, 0);
    }
    if ($rating > 89) {
        $fill = ImageColorAllocate($image, 197, 6, 6);
    }
    if ($rating > 100) {
        echo "Overload Error!";
        exit;
    }
    $back = ImageColorAllocate($image, 255, 255, 255);
    $border = ImageColorAllocate($image, 151, 151, 151);
    ImageFilledRectangle($image, 0, 0, $width - 1, $height - 1, $back);
    ImageFilledRectangle($image, 1, 1, $ratingbar, $height - 1, $fill);
    ImageRectangle($image, 0, 0, $width - 1, $height - 1, $border);
    imagePNG($image);
    imagedestroy($image);
}
开发者ID:jamiebatch452,项目名称:Open-Game-Panel,代码行数:25,代码来源:bar.php

示例5: save_img

 public function save_img($path)
 {
     // Resize
     if ($this->resize) {
         $this->img_output = ImageCreateTrueColor($this->x_output, $this->y_output);
         ImageCopyResampled($this->img_output, $this->img_input, 0, 0, 0, 0, $this->x_output, $this->y_output, $this->x_input, $this->y_input);
     }
     // Save JPEG
     if ($this->format == "JPG" or $this->format == "JPEG") {
         if ($this->resize) {
             imageJPEG($this->img_output, $path, $this->quality);
         } else {
             copy($this->img_src, $path);
         }
     } elseif ($this->format == "PNG") {
         if ($this->resize) {
             imagePNG($this->img_output, $path);
         } else {
             copy($this->img_src, $path);
         }
     } elseif ($this->format == "GIF") {
         if ($this->resize) {
             imageGIF($this->img_output, $path);
         } else {
             copy($this->img_src, $path);
         }
     }
 }
开发者ID:jcandrew1966,项目名称:as_woodhouse,代码行数:28,代码来源:gd.php

示例6: createImage

 public function createImage($text = '', $fontSize = 5)
 {
     // GD's built-in fonts are numbered from 1 - 5
     $font_size = $fontSize;
     // Calculate the appropriate image size
     $image_height = intval(imageFontHeight($font_size) * 2);
     $image_width = intval(strlen($text) * imageFontWidth($font_size) * 1.3);
     // Create the image
     $image = imageCreate($image_width, $image_height);
     // Create the colors to use in the image
     // gray background
     $back_color = imageColorAllocate($image, 216, 216, 216);
     // blue text
     $text_color = imageColorAllocate($image, 0, 0, 255);
     // black border
     $rect_color = imageColorAllocate($image, 0, 0, 0);
     // Figure out where to draw the text
     // (Centered horizontally and vertically
     $x = ($image_width - imageFontWidth($font_size) * strlen($text)) / 2;
     $y = ($image_height - imageFontHeight($font_size)) / 2;
     // Draw the text
     imageString($image, $font_size, $x, $y, $text, $text_color);
     // Draw a black border
     imageRectangle($image, 0, 0, imageSX($image) - 1, imageSY($image) - 1, $rect_color);
     // Send the image to the browser
     header('Content-Type: image/png');
     imagePNG($image);
     imageDestroy($image);
 }
开发者ID:puncoz,项目名称:presentation,代码行数:29,代码来源:images.php

示例7: TextToImage

function TextToImage($text, $separate_line_after_chars = 40, $size = 24, $rotate = 0, $padding = 2, $transparent = true, $color = array('red' => 0, 'grn' => 0, 'blu' => 0), $bg_color = array('red' => 255, 'grn' => 255, 'blu' => 255))
{
    $amount_of_lines = ceil(strlen($text) / $separate_line_after_chars);
    $x = explode("\n", $text);
    $final = '';
    foreach ($x as $key => $value) {
        $returnes = '';
        do {
            $first_part = mb_substr($value, 0, $separate_line_after_chars, 'utf-8');
            $value = "\n" . mb_substr($value, $separate_line_after_chars, null, 'utf-8');
            $returnes .= $first_part;
        } while (mb_strlen($value, 'utf-8') > $separate_line_after_chars);
        $final .= $returnes . "\n";
    }
    $text = $final;
    $width = $height = $offset_x = $offset_y = 0;
    $font = $_SERVER['DOCUMENT_ROOT'] . '/assets/css/journal.ttf';
    // get the font height.
    $bounds = ImageTTFBBox($size, $rotate, $font, "W");
    if ($rotate < 0) {
        $font_height = abs($bounds[7] - $bounds[1]);
    } elseif ($rotate > 0) {
        $font_height = abs($bounds[1] - $bounds[7]);
    } else {
        $font_height = abs($bounds[7] - $bounds[1]);
    }
    // determine bounding box.
    $bounds = ImageTTFBBox($size, $rotate, $font, $text);
    if ($rotate < 0) {
        $width = abs($bounds[4] - $bounds[0]);
        $height = abs($bounds[3] - $bounds[7]);
        $offset_y = $font_height;
        $offset_x = 0;
    } elseif ($rotate > 0) {
        $width = abs($bounds[2] - $bounds[6]);
        $height = abs($bounds[1] - $bounds[5]);
        $offset_y = abs($bounds[7] - $bounds[5]) + $font_height;
        $offset_x = abs($bounds[0] - $bounds[6]);
    } else {
        $width = abs($bounds[4] - $bounds[6]);
        $height = abs($bounds[7] - $bounds[1]);
        $offset_y = $font_height;
        $offset_x = 0;
    }
    $image = imagecreate($width + $padding * 2 + 1, $height + $padding * 2 + 1);
    $background = ImageColorAllocate($image, $bg_color['red'], $bg_color['grn'], $bg_color['blu']);
    $foreground = ImageColorAllocate($image, $color['red'], $color['grn'], $color['blu']);
    if ($transparent) {
        ImageColorTransparent($image, $background);
    }
    ImageInterlace($image, true);
    // render the image
    ImageTTFText($image, $size, $rotate, $offset_x + $padding, $offset_y + $padding, $foreground, $font, $text);
    imagealphablending($image, true);
    imagesavealpha($image, true);
    // output PNG object.
    imagePNG($image, 'signature.png');
    imagedestroy($image);
}
开发者ID:kevwaddell,项目名称:tlw-echosign,代码行数:59,代码来源:text-to-img.php

示例8: create

 function create($text)
 {
     $img = imagecreatefrompng("skins/icon.png");
     $black = imageColorAllocate($img, 0, 0, 0);
     $white = imageColorAllocate($img, 255, 255, 255);
     imageString($img, 5, 20, 3, $text, $white);
     imagePNG($img);
 }
开发者ID:Parashutik,项目名称:ReloadCMS,代码行数:8,代码来源:captcha.php

示例9: sendImage

function sendImage($img)
{
    if (!$img) {
        sendErrorImageAndDie("Invalid image object");
    } else {
        header("Content-type: image/png");
        imagePNG($img);
        imageDestroy($img);
    }
}
开发者ID:adamisom,项目名称:chessimager,代码行数:10,代码来源:ChessImagerUtils.php

示例10: Generate

 function Generate($imgName)
 {
     //        $this->GenStr();
     $this->img = imageCreate(200, 50);
     $this->GenColors();
     $this->PutLetters();
     $this->PutEllipses();
     $this->PutLines();
     imagePNG($this->img, $imgName);
     return $this->strCheck;
 }
开发者ID:askovorodka,项目名称:sqc,代码行数:11,代码来源:captcha.class.php

示例11: getRawPNG

 public function getRawPNG()
 {
     if ($this->avatar) {
         ob_start();
         imagePNG($this->avatar);
         $raw = ob_get_contents();
         ob_end_clean();
         return $raw;
     }
     return false;
 }
开发者ID:hfroese,项目名称:mediawiki-extensions-BlueSpiceExtensions,代码行数:11,代码来源:instantavatar.php

示例12: write

 public function write($path, $quality, $format = 'jpg')
 {
     if (!$this->image) {
         return false;
     }
     if ($format === 'png') {
         imagePNG($this->image, $path);
     } else {
         imageJPEG($this->image, $path, $quality);
     }
     return true;
 }
开发者ID:Norvares,项目名称:nemex,代码行数:12,代码来源:image.php

示例13: text2image

function text2image($height, $text)
{
header("Content-type: image/png");
$width = $height * strlen($text)/ 5 * 2;
$font = "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf";
$image = imageCreate($width, $height);
$backgroundColor = imageColorAllocate($image, 255, 255, 255);
$textColor = imageColorAllocate($image, 0, 0, 0);
imagefttext($image, $height/2, 0, 0, $height/10*9, $textColor, $font, $text); 
imageInterlace($image, 1);
imageColorTransparent($image, $backgroundColor);
imagePNG($image);
}
开发者ID:pier22,项目名称:Band-Page-FB,代码行数:13,代码来源:text2image.php

示例14: draw

 function draw()
 {
     $width = 0;
     $height = 0;
     $offset_x = 0;
     $offset_y = 0;
     $bounds = array();
     $image = "";
     // get the font height.
     $bounds = ImageTTFBBox($this->size, $this->rot, $this->font, "W");
     if ($this->rot < 0) {
         $font_height = abs($bounds[7] - $bounds[1]);
     } else {
         if ($this->rot > 0) {
             $font_height = abs($bounds[1] - $bounds[7]);
         } else {
             $font_height = abs($bounds[7] - $bounds[1]);
         }
     }
     // determine bounding box.
     $bounds = ImageTTFBBox($this->size, $this->rot, $this->font, $this->msg);
     if ($this->rot < 0) {
         $width = abs($bounds[4] - $bounds[0]);
         $height = abs($bounds[3] - $bounds[7]);
         $offset_y = $font_height;
         $offset_x = 0;
     } else {
         if ($this->rot > 0) {
             $width = abs($bounds[2] - $bounds[6]);
             $height = abs($bounds[1] - $bounds[5]);
             $offset_y = abs($bounds[7] - $bounds[5]) + $font_height;
             $offset_x = abs($bounds[0] - $bounds[6]);
         } else {
             $width = abs($bounds[4] - $bounds[6]);
             $height = abs($bounds[7] - $bounds[1]);
             $offset_y = $font_height;
             $offset_x = 0;
         }
     }
     $image = imagecreate($width + $this->padX * 2 + 1, $height + $this->padY * 2 + 1);
     $background = ImageColorAllocate($image, $this->bg_red, $this->bg_grn, $this->bg_blu);
     $foreground = ImageColorAllocate($image, $this->red, $this->grn, $this->blu);
     if ($this->transparent) {
         ImageColorTransparent($image, $background);
     }
     ImageInterlace($image, false);
     // render the image
     ImageTTFText($image, $this->size, $this->rot, $offset_x + $this->padX, $offset_y + $this->padY, $foreground, $this->font, $this->msg);
     // output PNG object.
     imagePNG($image);
 }
开发者ID:pankajsinghjarial,项目名称:SYLC-AMERICAN,代码行数:51,代码来源:toImage.php

示例15: save

 function save($save)
 {
     /* change ImageCreateTrueColor to ImageCreate if your GD not supported ImageCreateTrueColor function*/
     $this->img["des"] = ImageCreateTrueColor($this->img["lebar_thumb"], $this->img["tinggi_thumb"]);
     @imagecopyresized($this->img["des"], $this->img["src"], 0, 0, 0, 0, $this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]);
     if ($this->img["format"] == "JPG" || $this->img["format"] == "JPEG") {
         //JPEG
         imageJPEG($this->img["des"], "{$save}", $this->img["quality"]);
     } elseif ($this->img["format"] == "PNG") {
         //PNG
         imagePNG($this->img["des"], "{$save}");
     } elseif ($this->img["format"] == "GIF") {
         //GIF
         imageGIF($this->img["des"], "{$save}");
     } elseif ($this->img["format"] == "WBMP") {
         //WBMP
         imageWBMP($this->img["des"], "{$save}");
     }
 }
开发者ID:nateirwin,项目名称:custom-historic,代码行数:19,代码来源:ThumbNail.php


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