• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imagepng函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: run

 /**
  *	Génère l'avatar
  */
 public function run()
 {
     //On créer l'image avec les dimentions données
     $image = imagecreate($this->_size, $this->_size);
     //On créer la couleur en fonction du hash de la chaine de caractères
     $color = imagecolorallocate($image, hexdec(substr($this->_color, 0, 2)), hexdec(substr($this->_color, 2, 2)), hexdec(substr($this->_color, 4, 2)));
     //on défini le fond de l'image (blanc)
     $bg = imagecolorallocate($image, 255, 255, 255);
     //nombre de blocs à placer dans l'image (taille de l'image/taille des blocs)
     $c = $this->_size / $this->_blockSize;
     for ($x = 0; $x < ceil($c / 2); $x++) {
         for ($y = 0; $y < $c; $y++) {
             // Si le nombre est pair $pixel vaut true sinon $pixel vaut false
             $pixel = hexdec($this->_hash[(int) ($x * ceil($c / 2)) + $y]) % 2 == 0;
             if ($pixel) {
                 $pixelColor = $color;
             } else {
                 $pixelColor = $bg;
             }
             // On place chaque bloc de l'image
             //imagefilledrectangle($image, $x*$this->_blockSize, $y*$this->_blockSize, ($x+1)*$this->_blockSize, ($y+1)*$this->_blockSize, $pixelColor);
             //imagefilledrectangle($image, $this->_size-$x*$this->_blockSize, $y*$this->_blockSize, $this->_size-($x+1)*$this->_blockSize, ($y+1)*$this->_blockSize, $pixelColor);
             imagefilledrectangle($image, $x * $this->_blockSize, $y * $this->_blockSize, ($x + 1) * $this->_blockSize, ($y + 1) * $this->_blockSize, $pixelColor);
             imagefilledrectangle($image, $this->_size - $x * $this->_blockSize, $y * $this->_blockSize, $this->_size - ($x + 1) * $this->_blockSize, ($y + 1) * $this->_blockSize, $pixelColor);
         }
     }
     ob_start();
     imagepng($image);
     //on place l'image en mémoire
     $this->_image = ob_get_contents();
     ob_clean();
 }
开发者ID:JulienCoutault,项目名称:Web,代码行数:35,代码来源:RandomAvatar.php


示例2: getAvatar

 public function getAvatar($string, $widthHeight = 12, $theme = 'default')
 {
     $widthHeight = max($widthHeight, 12);
     $md5 = md5($string);
     $fileName = _TMP_DIR_ . '/' . $md5 . '.png';
     if ($this->tmpFileExists($fileName)) {
         return $fileName;
     }
     // Create seed.
     $seed = intval(substr($md5, 0, 6), 16);
     mt_srand($seed);
     $body = array('legs' => mt_rand(0, count($this->availableParts[$theme]['legs']) - 1), 'hair' => mt_rand(0, count($this->availableParts[$theme]['hair']) - 1), 'arms' => mt_rand(0, count($this->availableParts[$theme]['arms']) - 1), 'body' => mt_rand(0, count($this->availableParts[$theme]['body']) - 1), 'eyes' => mt_rand(0, count($this->availableParts[$theme]['eyes']) - 1), 'mouth' => mt_rand(0, count($this->availableParts[$theme]['mouth']) - 1));
     // Avatar random parts.
     $parts = array('legs' => $this->availableParts[$theme]['legs'][$body['legs']], 'hair' => $this->availableParts[$theme]['hair'][$body['hair']], 'arms' => $this->availableParts[$theme]['arms'][$body['arms']], 'body' => $this->availableParts[$theme]['body'][$body['body']], 'eyes' => $this->availableParts[$theme]['eyes'][$body['eyes']], 'mouth' => $this->availableParts[$theme]['mouth'][$body['mouth']]);
     $avatar = imagecreate($widthHeight, $widthHeight);
     imagesavealpha($avatar, true);
     imagealphablending($avatar, false);
     $background = imagecolorallocate($avatar, 0, 0, 0);
     $line_colour = imagecolorallocate($avatar, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55);
     imagecolortransparent($avatar, $background);
     imagefilledrectangle($avatar, 0, 0, $widthHeight, $widthHeight, $background);
     // Fill avatar with random parts.
     foreach ($parts as &$part) {
         $this->drawPart($part, $avatar, $widthHeight, $line_colour, $background);
     }
     imagepng($avatar, $fileName);
     imagecolordeallocate($avatar, $line_colour);
     imagecolordeallocate($avatar, $background);
     imagedestroy($avatar);
     return $fileName;
 }
开发者ID:recallfx,项目名称:monsterid.php,代码行数:31,代码来源:MonsterId.php


示例3: smart_spam

function smart_spam($code)
{
    @putenv('GDFONTPATH=' . realpath('.'));
    $font = 'FONT.TTF';
    // antispam image height
    $height = 40;
    // antispam image width
    $width = 110;
    $font_size = $height * 0.6;
    $image = @imagecreate($width, $height);
    $background_color = @imagecolorallocate($image, 255, 255, 255);
    $noise_color = @imagecolorallocate($image, 20, 40, 100);
    /* add image noise */
    for ($i = 0; $i < $width * $height / 4; $i++) {
        @imageellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
    }
    /* render text */
    $text_color = @imagecolorallocate($image, 20, 40, 100);
    @imagettftext($image, $font_size, 0, 7, 29, $text_color, $font, $code) or die('Cannot render TTF text.');
    //output image to the browser *//*
    header('Content-Type: image/png');
    @imagepng($image) or die('imagepng error!');
    @imagedestroy($image);
    exit;
}
开发者ID:JozefAB,项目名称:neoacu,代码行数:25,代码来源:captcha.php


示例4: save

 function save($handle, $uri = null, $compression = 9, $filters = PNG_ALL_FILTERS)
 {
     if ($compression > 9) {
         $compression *= 9 / 100;
     }
     return imagepng($handle, $uri, $compression, $filters);
 }
开发者ID:ZyXelP,项目名称:oxwall,代码行数:7,代码来源:PNG.php


示例5: GetPartialImage

function GetPartialImage($url)
{
	$W = 150;
	$H = 130;
	$F = 80;
	$STEP = 1.0 / $F;
	$im = imagecreatefromjpeg($url);
	$dest = imagecreatetruecolor($W, $H);
	imagecopy($dest, $im, 0, 0, 35, 40, $W, $H);
	
	$a = 1;
	for( $y = $H - $F; $y < $H; $y++ )
	{
		for ( $x = 0; $x < $W; $x++ )
		{
			$i = imagecolorat($dest, $x, $y);
			$c = imagecolorsforindex($dest, $i);
			$c = imagecolorallocate($dest, 
				a($c['red'], $a),
				a($c['green'], $a), 
				a($c['blue'], $a)
			);
			imagesetpixel($dest, $x, $y, $c);
		}
		$a -= $STEP;
	}
	
	header('Content-type: image/png');
	imagepng($dest);
	imagedestroy($dest);
	imagedestroy($im);
}
开发者ID:ryanknu,项目名称:Cuber,代码行数:32,代码来源:image.php


示例6: makeDataMatrix

function makeDataMatrix($code, $path)
{
    $x = 70;
    // barcode center
    $y = 70;
    // barcode center
    $height = 125;
    // barcode height in 1D ; module size in 2D
    $width = 4;
    // barcode height in 1D ; not use in 2D
    $angle = 90;
    // rotation in degrees : nb : non horizontable barcode might not be usable because of pixelisation
    $type = 'datamatrix';
    $im = imagecreatetruecolor(140, 140);
    $black = ImageColorAllocate($im, 0x0, 0x0, 0x0);
    $white = ImageColorAllocate($im, 0xff, 0xff, 0xff);
    $red = ImageColorAllocate($im, 0xff, 0x0, 0x0);
    $blue = ImageColorAllocate($im, 0x0, 0x0, 0xff);
    imagefilledrectangle($im, 0, 0, 140, 140, $white);
    $data = \BarcodeGEN::gd($im, $black, $x, $y, $angle, $type, array('code' => $code), $width, $height);
    /*for($i=1; $i<5; $i++){
          drawCross($im, $blue, $data['p'.$i]['x'], $data['p'.$i]['y']);
      }*/
    imagepng($im, $path);
    imagedestroy($im);
}
开发者ID:kesslerdev,项目名称:laposte,代码行数:26,代码来源:Barcode.php


示例7: save

 public function save()
 {
     $maxHeight = 0;
     $width = 0;
     foreach ($this->_segmentsArray as $segment) {
         $maxHeight = max($maxHeight, $segment->height);
         $width += $segment->width;
     }
     // create our canvas
     $img = imagecreatetruecolor($width, $maxHeight);
     $background = imagecolorallocatealpha($img, 255, 255, 255, 127);
     imagefill($img, 0, 0, $background);
     imagealphablending($img, false);
     imagesavealpha($img, true);
     // start placing our images on a single x axis
     $xPos = 0;
     foreach ($this->_segmentsArray as $segment) {
         $tmp = imagecreatefromjpeg($segment->pathToImage);
         imagecopy($img, $tmp, $xPos, 0, 0, 0, $segment->width, $segment->height);
         $xPos += $segment->width;
         imagedestroy($tmp);
     }
     // create our final output image.
     imagepng($img, $this->_saveToPath);
 }
开发者ID:ejacobs,项目名称:css-sprite,代码行数:25,代码来源:CssSprite.php


示例8: getCode

function getCode($num, $w, $h)
{
    // 去掉了 0 1 O l 等
    $str = "23456789abcdefghijkmnpqrstuvwxyz";
    $code = '';
    for ($i = 0; $i < $num; $i++) {
        $code .= $str[mt_rand(0, strlen($str) - 1)];
    }
    //将生成的验证码写入session,备验证页面使用
    $_SESSION["my_checkcode"] = $code;
    //创建图片,定义颜色值
    Header("Content-type: image/PNG");
    $im = imagecreate($w, $h);
    $black = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
    $gray = imagecolorallocate($im, 118, 151, 199);
    $bgcolor = imagecolorallocate($im, 235, 236, 237);
    //画背景
    imagefilledrectangle($im, 0, 0, $w, $h, $bgcolor);
    //画边框
    imagerectangle($im, 0, 0, $w - 1, $h - 1, $gray);
    //imagefill($im, 0, 0, $bgcolor);
    //在画布上随机生成大量点,起干扰作用;
    for ($i = 0; $i < 80; $i++) {
        imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
    }
    //将字符随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
    $strx = rand(5, 10);
    for ($i = 0; $i < $num; $i++) {
        $strpos = rand(1, 6);
        imagestring($im, 20, $strx, $strpos, substr($code, $i, 1), $black);
        $strx += $w / 5;
    }
    imagepng($im);
    imagedestroy($im);
}
开发者ID:hanpc,项目名称:chushen,代码行数:35,代码来源:code_char.php


示例9: __image

 private static function __image()
 {
     self::__background();
     self::__adulterate();
     self::__font();
     header("Expires: 0" . PHP_EOL);
     header("Cache-Control: no-cache" . PHP_EOL);
     header("Pragma: no-cache" . PHP_EOL);
     if (function_exists('imagejpeg')) {
         header('Content-type:image/jpeg' . PHP_EOL);
         $void = imagejpeg(self::$im);
     } else {
         if (function_exists('imagepng')) {
             header('Content-type:image/png' . PHP_EOL);
             $void = imagepng(self::$im);
         } else {
             if (function_exists('imagegif')) {
                 header('Content-type:image/gif' . PHP_EOL);
                 $void = imagegif(self::$im);
             } else {
                 return false;
             }
         }
     }
     imagedestroy(self::$im);
     return $void;
 }
开发者ID:Junred,项目名称:iCMS,代码行数:27,代码来源:iSeccode.class.php


示例10: createSemacode

 public function createSemacode($info, $name)
 {
     $_img = $this->_semacode->asGDImage($info, 120);
     header('Content-Type: image/png');
     imagepng($_img, "/tmp/{$name}.png");
     imagedestroy($_img);
 }
开发者ID:BackupTheBerlios,项目名称:openslx-svn,代码行数:7,代码来源:pdf.php


示例11: setUp

	function setUp() {
		parent::setUp();
		
		if(!file_exists(ASSETS_PATH)) mkdir(ASSETS_PATH);

		// Create a test folders for each of the fixture references
		$folderIDs = $this->allFixtureIDs('Folder');
		
		foreach($folderIDs as $folderID) {
			$folder = DataObject::get_by_id('Folder', $folderID);
			
			if(!file_exists(BASE_PATH."/$folder->Filename")) mkdir(BASE_PATH."/$folder->Filename");
		}
		
		// Create a test files for each of the fixture references
		$fileIDs = $this->allFixtureIDs('Image');
		foreach($fileIDs as $fileID) {
			$file = DataObject::get_by_id('Image', $fileID);
			$image = imagecreatetruecolor(300,300);
		
			imagepng($image, BASE_PATH."/$file->Filename");
			imagedestroy($image);
		
			$file->write();
		}
	}
开发者ID:redema,项目名称:sapphire,代码行数:26,代码来源:ImageTest.php


示例12: __construct

 /**
  * Class constructor generates the CAPTCHA image.
  *
  * @return blob the image
  * @access public
  */
 function __construct()
 {
     session_start();
     $image = imagecreate($this->width, $this->height);
     $random_str = $this->gen_str($this->chars_nr);
     #md5( microtime() );						// md5 to generate the random string
     $result_str = substr($random_str, 0, $this->chars_nr);
     //trim $chars_nr digit
     $bg_color = imagecolorallocate($image, $this->background_color['red'], $this->background_color['green'], $this->background_color['blue']);
     // background color
     $tx_color = imagecolorallocate($image, $this->text_color['red'], $this->text_color['gree'], $this->text_color['blue']);
     // text color
     for ($i = 0; $i <= $this->lines; $i++) {
         $line_color = imagecolorallocate($image, rand(0, 255), rand(0, 255), rand(0, 255));
         //line color
         imageline($image, rand(rand(-10, 100), rand(-10, 100)), rand(rand(-10, 100), rand(-10, 100)), rand(rand(-10, 100), rand(-10, 100)), rand(rand(-10, 100), rand(-10, 100)), $line_color);
         // Create lines on image
     }
     imagestring($image, 5, 20, 10, $result_str, $tx_color);
     // Draw a random string horizontally
     $_SESSION['key'] = $result_str;
     // Carry the data through session
     header("Content-type: image/png");
     // Out out the image
     imagepng($image);
     // Output image to browser
 }
开发者ID:rehash,项目名称:Repository,代码行数:33,代码来源:class.rshcaptcha.php


示例13: writeToCache

 function writeToCache($ID, $pChartObject)
 {
     /* Compute the paths */
     $TemporaryFile = $this->CacheFolder . "/tmp_" . rand(0, 1000) . ".png";
     $Database = $this->CacheFolder . "/" . $this->CacheDB;
     $Index = $this->CacheFolder . "/" . $this->CacheIndex;
     /* Flush the picture to a temporary file */
     imagepng($pChartObject->Picture, $TemporaryFile);
     /* Retrieve the files size */
     $PictureSize = filesize($TemporaryFile);
     $DBSize = filesize($Database);
     /* Save the index */
     $Handle = fopen($Index, "a");
     fwrite($Handle, $ID . "," . $DBSize . "," . $PictureSize . "," . time() . ",0      \r\n");
     fclose($Handle);
     /* Get the picture raw contents */
     $Handle = fopen($TemporaryFile, "r");
     $Raw = fread($Handle, $PictureSize);
     fclose($Handle);
     /* Save the picture in the solid database file */
     $Handle = fopen($Database, "a");
     fwrite($Handle, $Raw);
     fclose($Handle);
     /* Remove temporary file */
     unlink($TemporaryFile);
 }
开发者ID:conjuringtricks,项目名称:Pony,代码行数:26,代码来源:pCache.class.php


示例14: createCode

 function createCode($len = 4)
 {
     $width = 100;
     $height = 50;
     $size = 22;
     //字体大小
     $font = ROOT_PATH . '/static/font/arial.ttf';
     //字体
     $img = imagecreatetruecolor($width, $height);
     //创建画布
     $bgimg = imagecreatefromjpeg(ROOT_PATH . '/static/background/' . rand(1, 5) . '.jpg');
     //生成背景图片
     $bg_x = rand(0, 100);
     //随机招贴画布起始X轴坐标
     $bg_y = rand(0, 50);
     //随机招贴画布起始Y轴坐标
     imagecopy($img, $bgimg, 0, 0, $bg_x, $bg_y, $bg_x + $width, $bg_y + $height);
     //把背景图片$bging粘贴的画布上
     $str = $this->creaStr($len);
     //字符串
     for ($i = 0, $j = 5; $i < 4; $i++) {
         $array = array(-1, 1);
         $p = array_rand($array);
         $an = $array[$p] * mt_rand(1, 10);
         //扭曲角度
         imagettftext($img, $size, $an, $j + 5, 34, imagecolorallocate($img, rand(0, 100), rand(0, 100), rand(0, 100)), $font, $str[$i]);
         //生成验证字符窜
         $j += 20;
     }
     cookie('captchacode', strtolower($str));
     header('Content-type:image/png');
     imagepng($img);
     imagedestroy($img);
 }
开发者ID:xy113,项目名称:XiangBaLaoServer,代码行数:34,代码来源:class.Captcha.php


示例15: get

 /**
  * 生成验证码
  * @param  string $file 图片保存文件名,不指定则图片会被直接输出
  * @return null
  */
 public function get($file = "")
 {
     $support = $this->support();
     list($code, $answer) = $this->generateCode();
     $image = null;
     @session_start();
     $_SESSION['vitex.captcha.answer'] = strtolower($answer);
     if ($support == 'imagick') {
         $image = new \Imagick();
         $image->newImage($this->width, $this->height, "none");
         $image->setImageFormat('png');
         $image = $this->imagickLine($image, $this->linenum);
         $image = $this->imagickDrawText($image, $code);
         $image->swirlImage(30);
         $image->oilPaintImage(1);
         if ($file) {
             $image->writeImage($file);
         } else {
             header("Content-type:image/png");
             echo $image->getImageBlob();
         }
     } else {
         $image = imagecreate($this->width, $this->height);
         $color = imagecolorallocate($image, 255, 255, 255);
         imagecolortransparent($image, $color);
         $this->gdLine($image, $this->linenum);
         $this->gdDrawText($image, $code);
         if ($file) {
             imagepng($image, $file);
         } else {
             header("Content-type: image/jpeg; Cache-Control: no-store, no-cache, must-revalidate");
             imagepng($image);
         }
     }
 }
开发者ID:feixingbeibao,项目名称:vitexframework,代码行数:40,代码来源:Captcha.php


示例16: render

 /**
  * Render the gradient to an image
  **/
 public function render($width, $height, $format = 'png', $filename = null)
 {
     $image = $this->render_gd($width, $height);
     switch ($format) {
         case 'jpg':
         case 'jpeg':
         case 'jpe':
             if (empty($filename)) {
                 header('Content-Type: image/jpeg');
             }
             imagejpeg($image, $filename, 90);
             break;
         case 'gif':
             if (empty($filename)) {
                 header('Content-Type: image/gif');
             }
             imagegif($image, $filename);
             break;
         case 'png':
         default:
             if (empty($filename)) {
                 header('Content-Type: image/png');
             }
             imagepng($image, $filename, 9);
             break;
     }
     imagedestroy($image);
 }
开发者ID:Pesulap,项目名称:php-utils,代码行数:31,代码来源:linear-gradient.php


示例17: resizewidth

 static function resizewidth($width, $imageold, $imagenew)
 {
     $image_info = getimagesize($imageold);
     $image_type = $image_info[2];
     if ($image_type == IMAGETYPE_JPEG) {
         $image = imagecreatefromjpeg($imageold);
     } elseif ($this->image_type == IMAGETYPE_GIF) {
         $image = imagecreatefromgif($imageold);
     } elseif ($this->image_type == IMAGETYPE_PNG) {
         $image = imagecreatefrompng($imageold);
     }
     $ratio = imagesy($image) / imagesx($image);
     $height = $width * $ratio;
     //$width = imagesx($image) * $width/100;
     // $height = imagesx($image) * $width/100;
     $new_image = imagecreatetruecolor($width, $height);
     imagecopyresampled($new_image, $image, 0, 0, 0, 0, $width, $height, $image_info[0], $image_info[1]);
     $image = $new_image;
     $compression = 75;
     $permissions = null;
     if ($image_type == IMAGETYPE_JPEG) {
         imagejpeg($image, $imagenew, $compression);
     } elseif ($image_type == IMAGETYPE_GIF) {
         imagegif($image, $imagenew);
     } elseif ($image_type == IMAGETYPE_PNG) {
         imagepng($image, $imagenew);
     }
     if ($permissions != null) {
         chmod($imagenew, $permissions);
     }
 }
开发者ID:blackorwhite1233,项目名称:fakekinhdoanh,代码行数:31,代码来源:SimpleImage.php


示例18: create_pic

function create_pic($upfile, $new_path, $width)
{
    $quality = 100;
    $image_path = $upfile;
    $image_info = getimagesize($image_path);
    $exname = '';
    //1  =  GIF,  2  =  JPG,  3  =  PNG,  4  =  SWF,  5  =  PSD,  6  =  BMP,  7  =  TIFF(intel  byte  order),  8  =  TIFF(motorola  byte  order),  9  =  JPC,  10  =  JP2,  11  =  JPX,  12  =  JB2,  13  =  SWC,  14  =  IFF
    switch ($image_info[2]) {
        case 1:
            @($image = imagecreatefromgif($image_path));
            $exname = 'gif';
            break;
        case 2:
            @($image = imagecreatefromjpeg($image_path));
            $exname = 'jpg';
            break;
        case 3:
            @($image = imagecreatefrompng($image_path));
            $exname = 'png';
            break;
        case 6:
            @($image = imagecreatefromwbmp($image_path));
            $exname = 'wbmp';
            break;
    }
    $T_width = $image_info[0];
    $T_height = $image_info[1];
    if (!empty($image)) {
        $image_x = imagesx($image);
        $image_y = imagesy($image);
    } else {
        return FALSE;
    }
    @chmod($new_path, 0777);
    if ($image_x > $width) {
        $x = $width;
        $y = intval($x * $image_y / $image_x);
    } else {
        @copy($image_path, $new_path . '.' . $exname);
        return $exname;
    }
    $newimage = imagecreatetruecolor($x, $y);
    imagecopyresampled($newimage, $image, 0, 0, 0, 0, $x, $y, $image_x, $image_y);
    switch ($image_info[2]) {
        case 1:
            imagegif($newimage, $new_path . '.gif', $quality);
            break;
        case 2:
            imagejpeg($newimage, $new_path . '.jpg', $quality);
            break;
        case 3:
            imagepng($newimage, $new_path . '.png', $quality);
            break;
        case 6:
            imagewbmp($newimage, $new_path . '.wbmp', $quality);
            break;
    }
    imagedestroy($newimage);
    return $exname;
}
开发者ID:yunsite,项目名称:cyaskuc,代码行数:60,代码来源:global.func.php


示例19: mkthumb

function mkthumb($img_src, $img_width = "100", $img_height = "100", $folder_scr = "include/files", $des_src = "include/files")
{
    // Größe und Typ ermitteln
    list($src_width, $src_height, $src_typ) = getimagesize($folder_scr . "/" . $img_src);
    if (!$src_typ) {
        return false;
    }
    // calculate new size
    if ($src_width >= $src_height) {
        $new_image_height = $src_height / $src_width * $img_width;
        $new_image_width = $img_width;
        if ($new_image_height > $img_height) {
            $new_image_width = $new_image_width / $new_image_height * $img_height;
            $new_image_height = $img_height;
        }
    } else {
        $new_image_width = $src_width / $src_height * $img_height;
        $new_image_height = $img_height;
        if ($new_image_width > $img_width) {
            $new_image_height = $new_image_height / $new_image_width * $img_width;
            $new_image_width = $img_width;
        }
    }
    // for the case that the thumbnail would be bigger then the original picture
    if ($new_image_height > $src_height) {
        $new_image_width = $new_image_width * $src_height / $new_image_height;
        $new_image_height = $src_height;
    }
    if ($new_image_width > $src_width) {
        $new_image_height = $new_image_height * $new_image_width / $src_width;
        $new_image_width = $src_width;
    }
    if ($src_typ == 1) {
        $image = imagecreatefromgif($folder_scr . "/" . $img_src);
        $new_image = imagecreate($new_image_width, $new_image_height);
        imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_image_width, $new_image_height, $src_width, $src_height);
        imagegif($new_image, $des_src . "/" . $img_src . "_thumb", 100);
        imagedestroy($image);
        imagedestroy($new_image);
        return true;
    } elseif ($src_typ == 2) {
        $image = imagecreatefromjpeg($folder_scr . "/" . $img_src);
        $new_image = imagecreatetruecolor($new_image_width, $new_image_height);
        imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_image_width, $new_image_height, $src_width, $src_height);
        imagejpeg($new_image, $des_src . "/" . $img_src . "_thumb", 100);
        imagedestroy($image);
        imagedestroy($new_image);
        return true;
    } elseif ($src_typ == 3) {
        $image = imagecreatefrompng($folder_scr . "/" . $img_src);
        $new_image = imagecreatetruecolor($new_image_width, $new_image_height);
        imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_image_width, $new_image_height, $src_width, $src_height);
        imagepng($new_image, $des_src . "/" . $img_src . "_thumb");
        imagedestroy($image);
        imagedestroy($new_image);
        return true;
    } else {
        return false;
    }
}
开发者ID:GoeGaming,项目名称:bans.sevenelevenclan.org,代码行数:60,代码来源:thumbs.inc.php


示例20: graph_error

function graph_error($string)
{
    global $vars, $config, $debug, $graphfile;
    $vars['bg'] = 'FFBBBB';
    include 'includes/graphs/common.inc.php';
    $rrd_options .= ' HRULE:0#555555';
    $rrd_options .= " --title='" . $string . "'";
    rrdtool_graph($graphfile, $rrd_options);
    if ($height > '99') {
        shell_exec($rrd_cmd);
        d_echo('<pre>' . $rrd_cmd . '</pre>');
        if (is_file($graphfile) && !$debug) {
            header('Content-type: image/png');
            $fd = fopen($graphfile, 'r');
            fpassthru($fd);
            fclose($fd);
            unlink($graphfile);
            exit;
        }
    } else {
        if (!$debug) {
            header('Content-type: image/png');
        }
        $im = imagecreate($width, $height);
        $px = (imagesx($im) - 7.5 * strlen($string)) / 2;
        imagestring($im, 3, $px, $height / 2 - 8, $string, imagecolorallocate($im, 128, 0, 0));
        imagepng($im);
        imagedestroy($im);
        exit;
    }
}
开发者ID:greggcz,项目名称:librenms,代码行数:31,代码来源:graph.inc.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imagesX函数代码示例发布时间:2022-05-24
下一篇:
PHP imagepalettecopy函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap