本文整理汇总了PHP中imagePNG函数的典型用法代码示例。如果您正苦于以下问题:PHP imagePNG函数的具体用法?PHP imagePNG怎么用?PHP imagePNG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagePNG函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: save
function save($save = "", $gd_version)
{
if ($gd_version == 2) {
$this->img["des"] = imagecreatetruecolor($this->img["lebar_thumb"], $this->img["tinggi_thumb"]);
@imagecopyresampled($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 ($gd_version == 1) {
$this->img["des"] = imagecreate($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}");
}
// Memory cleanup
@imageDestroy($this->img["des"]);
}
开发者ID:hyrmedia,项目名称:modules,代码行数:20,代码来源:class.thumbnail.inc.php
示例17: sendImage
public function sendImage($img)
{
if (!$img) {
$this->sendErrorImageAndDie("Invalid image object");
} else {
if ($this->base64ImageOut) {
ob_start();
imagePNG($img);
$image_data = ob_get_contents();
ob_end_clean();
// return the base64 encoded image,
// this way it doesn't send an image/png header
// and simply returns the string
return $image_data_base64 = base64_encode($image_data);
} else {
// The entire page that instantiates the class becomes an image
header("Content-type: image/png");
imagePNG($img);
imageDestroy($img);
}
}
}
开发者ID:elioair,项目名称:chesscaptcha,代码行数:22,代码来源:BoardImageCreator.php
示例18: generate_image
/**
* Create PNG of font name written with font TTF.
*/
public function generate_image()
{
$width = $height = $font_size = $left_margin = $background_color = $font_color = false;
extract($this->preview_attributes, EXTR_IF_EXISTS);
// Text Mask
$mask = imageCreate($width, $height);
$background = imageColorAllocate($mask, $background_color[0], $background_color[1], $background_color[2]);
$foreground = imageColorAllocate($mask, $font_color[0], $font_color[1], $font_color[2]);
$ttf_path = $this->font->maybe_get_remote_ttf();
if (!file_exists($ttf_path)) {
wp_die('Could not load $ttf_path: ' . $ttf_path);
}
// Text
$y = $this->get_centered_y_coordinate($font_size, $ttf_path, $this->font->family);
imagettftext($mask, $font_size, 0, $left_margin, $y, $foreground, $ttf_path, $this->font->family);
// White fill
$white = imageCreate($width, $height);
$background = imageColorAllocate($white, $background_color[0], $background_color[1], $background_color[2]);
// Image
$image = imagecreatetruecolor($width, $height);
imagesavealpha($image, true);
imagefill($image, 0, 0, imagecolorallocatealpha($image, 0, 0, 0, 127));
// Apply Mask to Image
for ($x = 0; $x < $width; $x++) {
for ($y = 0; $y < $height; $y++) {
$alpha = imagecolorsforindex($mask, imagecolorat($mask, $x, $y));
$alpha = 127 - floor($alpha['red'] / 2);
$color = imagecolorsforindex($white, imagecolorat($white, $x, $y));
imagesetpixel($image, $x, $y, imagecolorallocatealpha($image, $color['red'], $color['green'], $color['blue'], $alpha));
}
}
ob_start();
imagePNG($image);
$image = ob_get_clean();
$this->save_image($image);
// header("Content-type: image/png");
// echo $image;
}
开发者ID:Wordpress-Development,项目名称:styles,代码行数:41,代码来源:sfm-image-preview.php
示例19: drawRating
function drawRating()
{
if (isset($_GET['rating'])) {
$rating = $_GET['rating'];
} else {
$rating = 0;
}
if (isset($_GET['width'])) {
$width = $_GET['width'];
} else {
$width = 170;
}
if (isset($_GET['height'])) {
$height = $_GET['height'];
} else {
$height = 5;
}
$ratingbar = $rating / 100 * $width - 2;
$image = imagecreate($width, $height) or die("Cannot Create image");
$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:laiello,项目名称:rapidleech36b,代码行数:37,代码来源:bar.php
示例20: eval
}
}
($code = $plugins->load('images_rating_start')) ? eval($code) : null;
$ratings = array();
while ($row = $db->fetch_assoc($result)) {
$ratings[] = $row['rating'];
}
$ratingcounter = count($ratings);
if ($ratingcounter > 0) {
$rating = round((array_sum($ratings) / $ratingcounter + 1) * ($width / 2));
$avg = array_sum($ratings) / $ratingcounter;
} else {
$rating = $width / 2;
$avg = 0;
}
$five = ceil(($avg + 1) * 2.5);
header("Content-type: image/png");
$image = imagecreate($width + 2, $height + 2);
$back = ImageHexColorAllocate($image, 'ffffff');
$fill = ImageHexColorAllocate($image, $colors[$five]);
$border = ImageHexColorAllocate($image, '000000');
ImageFilledRectangle($image, 1, 1, $width, $height, $back);
ImageFilledRectangle($image, 1, 1, $rating, $height, $fill);
ImageRectangle($image, 0, 0, $width + 1, $height + 1, $border);
imagePNG($image);
imagedestroy($image);
}
($code = $plugins->load('images_end')) ? eval($code) : null;
$slog->updatelogged();
$zeitmessung = t2();
$db->close();
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:31,代码来源:images.php
注:本文中的imagePNG函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论