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


PHP imagegd函数代码示例

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


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

示例1: making

 public function making($dst_w, $dst_h)
 {
     $thumb_img = imagecreatetruecolor($dst_w, $dst_h);
     imagecopyresampled($thumb_img, $this->image, 0, 0, 0, 0, $dst_w, $dst_h, $this->width, $this->height);
     ob_start();
     switch ($this->_mimetype) {
         case "gd2":
             imagegd2($thumb_img, null, 100);
             break;
         case "gd":
             imagegd($thumb_img, null, 100);
             break;
         case "gif":
             imagegif($thumb_img, null, 100);
             break;
         case "jpeg":
             imagejpeg($thumb_img, null, 100);
             break;
         case "jpg":
             imagejpeg($thumb_img, null, 100);
             break;
         case "png":
             imagepng($thumb_img, null, 9);
             break;
         case "webp":
             imagewebp($thumb_img, null, 100);
             break;
         default:
             throw new \yii\base\NotSupportedException("Unsupport imageX method!");
             break;
     }
     imagedestroy($this->image);
     //destory origin
     return ob_get_clean();
     //返回二进制数据流
 }
开发者ID:gtyd,项目名称:jira,代码行数:36,代码来源:Stream.php

示例2: save

 public function save($handle, $uri = null)
 {
     if ($uri == null) {
         return imagegd($handle);
     }
     return imagegd($handle, $uri);
 }
开发者ID:nooshin-mirzadeh,项目名称:web_2.0_benchmark,代码行数:7,代码来源:GD.php

示例3: save

 function save($handle, $uri = null)
 {
     if ($uri == null) {
         return imagegd($handle);
     } else {
         return imagegd($handle, $uri);
     }
 }
开发者ID:mjrouser,项目名称:cityapi,代码行数:8,代码来源:WideImage_Mapper_GD.php

示例4: compress

 /**
  * 按比例压缩图片
  * @param int $percent
  * @return string  二进制数据流
  */
 public function compress($percent)
 {
     $image = imagecreatefromstring($this->_StreamData);
     $width = imagesx($image);
     //原图width
     $height = imagesy($image);
     //原图height
     $t_w = $percent * $width;
     //缩略图width
     $t_h = $percent * $height;
     //缩略图height
     $thumb_img = imagecreatetruecolor($t_w, $t_h);
     imagecopyresampled($thumb_img, $image, 0, 0, 0, 0, $t_w, $t_h, $width, $height);
     ob_start();
     switch ($this->_mimetype) {
         case "gd2":
             imagegd2($thumb_img, null, 100);
             break;
         case "gd":
             imagegd($thumb_img, null, 100);
             break;
         case "gif":
             imagegif($thumb_img, null, 100);
             break;
         case "jpeg":
             imagejpeg($thumb_img, null, 100);
             break;
         case "jpg":
             imagejpeg($thumb_img, null, 100);
             break;
         case "png":
             imagepng($thumb_img, null, 100);
             break;
         default:
             throw new \yii\base\NotSupportedException("Unsupport imageX method!");
             break;
     }
     imagedestroy($image);
     //destory origin
     return ob_get_clean();
     //返回二进制数据流
 }
开发者ID:gtyd,项目名称:jira,代码行数:47,代码来源:ImageStreamHelper.php

示例5: dirname

<?php

$cwd = dirname(__FILE__);
echo "JPEG to GD1 conversion: ";
echo imagegd(imagecreatefromjpeg($cwd . "/conv_test.jpeg"), $cwd . "/test.gd1") ? 'ok' : 'failed';
echo "\n";
echo "JPEG to GD2 conversion: ";
echo imagegd2(imagecreatefromjpeg($cwd . "/conv_test.jpeg"), $cwd . "/test.gd2") ? 'ok' : 'failed';
echo "\n";
echo "GD1 to JPEG conversion: ";
echo imagejpeg(imagecreatefromgd($cwd . "/test.gd1"), $cwd . "/test_gd1.jpeg") ? 'ok' : 'failed';
echo "\n";
echo "GD2 to JPEG conversion: ";
echo imagejpeg(imagecreatefromgd2($cwd . "/test.gd2"), $cwd . "/test_gd2.jpeg") ? 'ok' : 'failed';
echo "\n";
@unlink($cwd . "/test.gd1");
@unlink($cwd . "/test.gd2");
@unlink($cwd . "/test_gd1.jpeg");
@unlink($cwd . "/test_gd2.jpeg");
开发者ID:badlamer,项目名称:hhvm,代码行数:19,代码来源:jpg2gd.php

示例6: _to

 /**
  * 将当前画布存放到文件中
  * @param resource $dst_im 目标文件的当前画布
  * @return resource 生成一个图片文件
  */
 public function _to($dst_im)
 {
     switch ($this->dst_img_ext) {
         case "gd2":
             imagegd2($dst_im, $this->dst_img);
             break;
         case "gd":
             imagegd($dst_im, $this->dst_img);
             break;
         case "gif":
             imagegif($dst_im, $this->dst_img);
             break;
         case "jpeg":
             imagejpeg($dst_im, $this->dst_img);
             break;
         case "jpg":
             imagejpeg($dst_im, $this->dst_img);
             break;
         case "png":
             imagepng($dst_im, $this->dst_img);
             break;
         default:
             break;
     }
     if (file_exists($this->dst_img)) {
         return TRUE;
     }
     return FALSE;
 }
开发者ID:gtyd,项目名称:jira,代码行数:34,代码来源:File.php

示例7: dirname

<?php

$cwd = dirname(__FILE__);
echo "XPM to GD1 conversion: ";
echo imagegd(imagecreatefromxpm($cwd . "/conv_test.xpm"), $cwd . "/test.gd1") ? 'ok' : 'failed';
echo "\n";
echo "XPM to GD2 conversion: ";
echo imagegd2(imagecreatefromxpm($cwd . "/conv_test.xpm"), $cwd . "/test.gd2") ? 'ok' : 'failed';
echo "\n";
@unlink($cwd . "/test.gd1");
@unlink($cwd . "/test.gd2");
开发者ID:badlamer,项目名称:hhvm,代码行数:11,代码来源:xpm2gd.php

示例8: imagecreate

<?php

$image = imagecreate(1, 1);
// 1px image
$tempdir = sys_get_temp_dir() . '/php-gdtest';
if (!file_exists($tempdir) && !is_dir($tempdir)) {
    mkdir($tempdir, 0777, true);
}
$userinput = "1";
// from post or get data
$temp = $tempdir . "/test" . $userinput . ".tmp";
echo "\nimagegd TEST\n";
imagegd($image, $temp);
var_dump(file_exists($tempdir . "/test1"));
var_dump(file_exists($tempdir . "/test1.tmp"));
foreach (glob($tempdir . "/test*") as $file) {
    unlink($file);
}
?>
$tempdir = sys_get_temp_dir(). '/php-gdtest';
foreach (glob($tempdir . "/test*") as $file ) { unlink($file); }
rmdir($tempdir);
开发者ID:alphaxxl,项目名称:hhvm,代码行数:22,代码来源:imagegd_nullbyte_injection.php

示例9: output

 /**
  * Output an image
  *
  * @param   resource handle
  * @return  bool
  */
 public function output($handle)
 {
     return imagegd($handle);
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:10,代码来源:GDStreamWriter.class.php

示例10: scale

 function scale($x, $y, $filename = '', $distImageType = '')
 {
     if ($distImageType == 'gif') {
         $distImage = imagecreatetruecolor($x, $y);
         $this->copyResampled($distImage, $this->image, $x, $y);
         if (empty($filename)) {
             header("Content-Type: image/gif");
             $res = @imagejpeg($distImage, '', $this->quality);
         } else {
             imagegif($distImage, $filename, $this->quality);
         }
     } else {
         if ($distImageType == 'jpg' || $distImageType == 'jpeg') {
             $distImage = imagecreatetruecolor($x, $y);
             $this->copyResampled($distImage, $this->image, $x, $y);
             if (empty($filename)) {
                 header("Content-Type: image/jpeg");
                 imagejpeg($distImage, '', $this->quality);
             } else {
                 imagejpeg($distImage, $filename, $this->quality);
             }
         } else {
             if ($distImageType == 'png') {
                 $distImage = imagecreatetruecolor($x, $y);
                 $this->copyResampled($distImage, $this->image, $x, $y);
                 if (empty($filename)) {
                     header("Content-Type: image/png");
                     imagepng($distImage, '', $this->quality);
                 } else {
                     imagepng($distImage, $filename, $this->quality);
                 }
             } else {
                 if ($distImageType == 'gd') {
                     $distImage = imagecreatetruecolor($x, $y);
                     $this->copyResampled($distImage, $this->image, $x, $y);
                     if (empty($filename)) {
                         header("Content-Type: image/gd");
                         imagegd($distImage, '', $this->quality);
                     } else {
                         imagegd($distImage, $filename, $this->quality);
                     }
                 } else {
                     if ($distImageType == 'wbmp') {
                         $distImage = imagecreatetruecolor($x, $y);
                         $this->copyResampled($distImage, $this->image, $x, $y);
                         if (empty($filename)) {
                             header("Content-Type: image/wbmp");
                             imagewbmp($distImage, '', $this->quality);
                         } else {
                             imagewbmp($distImage, $filename, $this->quality);
                         }
                     } else {
                         die("Couldn't transform image!");
                     }
                 }
             }
         }
     }
 }
开发者ID:innomatic-libs,项目名称:scaleimagelib,代码行数:59,代码来源:ScaleImage.php

示例11: output

 /**
  * Output an image
  *
  * @param   resource handle
  * @return  bool
  */
 protected function output($handle)
 {
     return imagegd($handle);
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:10,代码来源:GDStreamWriter.class.php

示例12: output

 function output($a_mime = 'image/png')
 {
     $mime = trim(strtolower($a_mime));
     if ($this->m_handle) {
         ob_start();
         switch ($mime) {
             case 'jpg':
             case 'jpeg':
             case 'image/jpeg':
                 imagejpeg($this->m_handle);
                 break;
             case 'png':
             case 'image/png':
                 imagepng($this->m_handle);
                 break;
             case 'gif':
             case 'image/gif':
                 imagegif($this->m_handle);
                 break;
             case 'gd':
             case 'image/gd':
                 imagegd($this->m_handle);
                 break;
             case 'gd2':
             case 'image/gd2':
                 imagegd2($this->m_handle);
                 break;
             case 'bmp':
             case 'wbmp':
             case 'image/bmp':
             case 'image/wbmp':
                 imagewbmp($this->m_handle);
                 break;
         }
         ZResponse::getInstance()->setContent(ob_get_contents());
         ob_end_clean();
     }
     ZResponse::getInstance()->setContentType($mime);
 }
开发者ID:BGCX261,项目名称:zoombi-svn-to-git,代码行数:39,代码来源:image.php

示例13: saveImage

 /**
  * Prints the Image
  * 
  * @param string $name
  * @param string $directory
  * @param string $imageType
  */
 private function saveImage($name, $directory, $imageType = 'png', $foreground = null)
 {
     switch ($imageType) {
         case 'jpg':
         case 'jpeg':
             imagejpeg($this->imageProperties[0], $directory . DIRECTORY_SEPARATOR . $name . '.' . $imageType);
             break;
         case 'gif':
             imagegif($this->imageProperties[0], $directory . DIRECTORY_SEPARATOR . $name . '.' . $imageType);
             break;
         case 'gd':
             imagegd($this->imageProperties[0], $directory . DIRECTORY_SEPARATOR . $name . '.' . $imageType);
             break;
         case 'gd2':
             imagegd2($this->imageProperties[0], $directory . DIRECTORY_SEPARATOR . $name . '.' . $imageType);
             break;
         case 'webp':
             imagewebp($this->imageProperties[0], $directory . DIRECTORY_SEPARATOR . $name . '.' . $imageType);
             break;
         case 'wbmp':
             imagewbmp($this->imageProperties[0], $directory . DIRECTORY_SEPARATOR . $name . '.' . $imageType, $foreground);
             break;
         case 'xbm':
             imagexbm($this->imageProperties[0], $directory . DIRECTORY_SEPARATOR . $name . '.' . $imageType, $foreground);
             break;
         case 'svg':
         default:
             imagepng($this->imageProperties[0], $directory . DIRECTORY_SEPARATOR . $name . '.' . $imageType);
     }
     imagedestroy($this->imageProperties[0]);
 }
开发者ID:rajibmp,项目名称:imager,代码行数:38,代码来源:DrawImage.php

示例14: header

<?php

//print_r($GLOBALS);
//die($GLOBALS['HTTP_RAW_POST_DATA']);
if (isset($GLOBALS['HTTP_RAW_POST_DATA'])) {
    $sData = $GLOBALS['HTTP_RAW_POST_DATA'];
    //header('Content-Type: application/octet-stream');
    header('Content-Type: image/jpg');
    header('Content-Disposition: attachment; filename=image.jpg');
    /*
    header('Content-Length: ' . strlen($sData));
    header('Pragma: cache');
    header('Cache-Control: public, must-revalidate, max-age=0');
    header('Connection: close');
    header('Expires: ' . date('r', time()+60*60));
    header('Last-Modified: ' . date('r', time()));
    */
    echo $sData;
    $oImg = imagecreatefromstring($sData);
    imagegd($oImg, null, 100);
    imagedestroy($oImg);
}
开发者ID:CreativeNotice,项目名称:scratch,代码行数:22,代码来源:exportimage.php

示例15: _types

 protected function _types()
 {
     $type = strtolower($this->type);
     if (!empty($this->save)) {
         $save = suffix($this->save, '.' . $type);
         $this->result['path'] = $save;
     } else {
         $save = NULL;
     }
     if ($type === 'jpeg') {
         if ($this->quality === 0) {
             $this->quality = 80;
         }
         imagejpeg($this->canvas, $save, $this->quality);
     } elseif ($type === 'png') {
         if ($this->quality === 0) {
             $this->quality = 8;
         }
         imagepng($this->canvas, $save, $this->quality);
     } elseif ($type === 'gif') {
         imagegif($this->canvas, $save);
     } elseif ($type === 'gd') {
         imagegd($this->canvas, $save);
     } elseif ($type === 'gd2') {
         imagegd2($this->canvas, $save, $this->quality);
     } elseif ($type === 'wbmp') {
         imagewbmp($this->canvas, $save, $this->quality);
     } elseif ($type === 'xbm') {
         imagexbm($this->canvas, $save, $this->quality);
     } elseif ($type === 'xpm') {
         imagexpm($this->canvas, $save, $this->quality);
     } elseif ($type === 'webp') {
         imagewebp($this->canvas, $save, $this->quality);
     }
     return $this;
 }
开发者ID:znframework,项目名称:znframework,代码行数:36,代码来源:InternalGD.php


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