PHP GD 库 缩略图 添加水印
- class cls_image {
- var $error_no = 0;
- var $error_msg = '';
- //var $images_dir = IMAGE_DIR;
- //var $data_dir = DATA_DIR;
- var $images_dir = GOODS_PATH1;
- var $data_dir = GOODS_PATH1;
- var $bgcolor = '';
- var $type_maping = array(
- 1 => 'image/gif',
- 2 => 'image/jpeg',
- 3 => 'image/png'
- );
- function __construct($bgcolor = '') {
- $this -> cls_image($bgcolor);
- }
- function cls_image($bgcolor = '') {
- if ($bgcolor) {
- $this -> bgcolor = $bgcolor;
- } else {
- $this -> bgcolor = "#FFFFFF";
- }
- }
- /**
- * 图片上传的处理函数
- *
- * @access public
- * @param array upload 包含上传的图片文件信息的数组
- * @param array dir 文件要上传在$this->data_dir下的目录名。如果为空图片放在则在$this->images_dir下以当月命名的目录下
- * @param array img_name 上传图片名称,为空则随机生成
- * @return mix 如果成功则返回文件名,否则返回false
- */
- function upload_image($upload, $dir = '', $img_name = '') {
- /* 没有指定目录默认为根目录images */
- // if (empty($dir))
- // {
- // /* 创建当月目录 */
- // $dir = date('Ym');
- // $dir = ROOT_PATH . $this->images_dir . '/' . $dir . '/';
- // }
- // else
- // {
- // /* 创建目录 */
- // $dir = ROOT_PATH . $this->data_dir . '/' . $dir . '/';
- // if ($img_name)
- // {
- // $img_name = $dir . $img_name; // 将图片定位到正确地址
- // }
- // }
- //
- /* 没有指定目录默认为admin/images/static01/goodsimage/image */
- if (empty($dir)) {
- /* 创建当月目录 */
- $dir = date('Ymd');
- $dir = ROOT_PATH . $this -> images_dir . '/' . $dir . '/';
- } else {
- /* 创建目录 */
- $dir = ROOT_PATH . $this -> data_dir . '/' . $dir . '/';
- if ($img_name) {
- $img_name = $dir . $img_name;
- // 将图片定位到正确地址
- }
- }
- /* 如果目标目录不存在,则创建它 */
- if (!file_exists($dir)) {
- if (!make_dir($dir)) {
- /* 创建目录失败 */
- $this -> error_msg = sprintf($GLOBALS['_LANG']['directory_readonly'], $dir);
- $this -> error_no = ERR_DIRECTORY_READONLY;
- return false;
- }
- }
- if (empty($img_name)) {
- $img_name = $this -> unique_name($dir);
- $img_name = $dir . $img_name . $this -> get_filetype($upload['name']);
- }
- if (!$this -> check_img_type($upload['type'])) {
- $this -> error_msg = $GLOBALS['_LANG']['invalid_upload_image_type'];
- $this -> error_no = ERR_INVALID_IMAGE_TYPE;
- return false;
- }
- /* 允许上传的文件类型 */
- //$allow_file_types = '|GIF|JPG|JEPG|PNG|BMP|SWF|';
- $allow_file_types = '|GIF|JPG|JEPG|BMP|';
- if (!check_file_type($upload['tmp_name'], $img_name, $allow_file_types)) {
- $this -> error_msg = $GLOBALS['_LANG']['invalid_upload_image_type'];
- $this -> error_no = ERR_INVALID_IMAGE_TYPE;
- return false;
- }
- if ($this -> move_file($upload, $img_name)) {
- return str_replace(ROOT_PATH, '', $img_name);
- } else {
- $this -> error_msg = sprintf($GLOBALS['_LANG']['upload_failure'], $upload['name']);
- $this -> error_no = ERR_UPLOAD_FAILURE;
- return false;
- }
- }
- /**
- * 创建图片的缩略图
- *
- * @access public
- * @param string $img 原始图片的路径
- * @param int $thumb_width 缩略图宽度
- * @param int $thumb_height 缩略图高度
- * @param strint $path 指定生成图片的目录名
- * @return mix 如果成功返回缩略图的路径,失败则返回false
- */
- function make_thumb($img, $thumb_width = 0, $thumb_height = 0, $path = '', $bgcolor = '', $fileName = "") {
- $gd = $this -> gd_version();
- //获取 GD 版本。0 表示没有 GD 库,1 表示 GD 1.x,2 表示 GD 2.x
- if ($gd == 0) {
- $this -> error_msg = $GLOBALS['_LANG']['missing_gd'];
- return false;
- }
- /* 检查缩略图宽度和高度是否合法 */
- if ($thumb_width == 0 && $thumb_height == 0) {
- return str_replace(ROOT_PATH, '', str_replace('\\', '/', realpath($img)));
- }
- /* 检查原始文件是否存在及获得原始文件的信息 */
- $org_info = @getimagesize($img);
- if (!$org_info) {
- $this -> error_msg = sprintf($GLOBALS['_LANG']['missing_orgin_image'], $img);
- $this -> error_no = ERR_IMAGE_NOT_EXISTS;
- return false;
- }
- if (!$this -> check_img_function($org_info[2])) {
- $this -> error_msg = sprintf($GLOBALS['_LANG']['nonsupport_type'], $this -> type_maping[$org_info[2]]);
- $this -> error_no = ERR_NO_GD;
- return false;
- }
- $img_org = $this -> img_resource($img, $org_info[2]);
- /* 原始图片以及缩略图的尺寸比例 */
- $scale_org = $org_info[0] / $org_info[1];
- /* 处理只有缩略图宽和高有一个为0的情况,这时背景和缩略图一样大 */
- if ($thumb_width == 0) {
- $thumb_width = $thumb_height * $scale_org;
- }
- if ($thumb_height == 0) {
- $thumb_height = $thumb_width / $scale_org;
- }
- /* 创建缩略图的标志符 */
- if ($gd == 2) {
- $img_thumb = imagecreatetruecolor($thumb_width, $thumb_height);
- } else {
- $img_thumb = imagecreate($thumb_width, $thumb_height);
- }
- /* 背景颜色 */
- if (empty($bgcolor)) {
- $bgcolor = $this -> bgcolor;
- }
- $bgcolor = trim($bgcolor, "#");
- sscanf($bgcolor, "%2x%2x%2x", $red, $green, $blue);
- $clr = imagecolorallocate($img_thumb, $red, $green, $blue);
- imagefilledrectangle($img_thumb, 0, 0, $thumb_width, $thumb_height, $clr);
- if ($org_info[0] / $thumb_width > $org_info[1] / $thumb_height) {
- $lessen_width = $thumb_width;
- $lessen_height = $thumb_width / $scale_org;
- } else {
- /* 原始图片比较高,则以高度为准 */
- $lessen_width = $thumb_height * $scale_org;
- $lessen_height = $thumb_height;
- }
- $dst_x = ($thumb_width - $lessen_width) / 2;
- $dst_y = ($thumb_height - $lessen_height) / 2;
- /* 将原始图片进行缩放处理 */
- if ($gd == 2) {
- imagecopyresampled($img_thumb, $img_org, $dst_x, $dst_y, 0, 0, $lessen_width, $lessen_height, $org_info[0], $org_info[1]);
- } else {
- imagecopyresized($img_thumb, $img_org, $dst_x, $dst_y, 0, 0, $lessen_width, $lessen_height, $org_info[0], $org_info[1]);
- }
- /* 创建当天目录 */
- if (empty($path)) {
- //$dir = ROOT_PATH . $this->images_dir . '/' . date('Ym').'/';
- /* 创建当天目录 */
- $dir = date('Ymd');
- $dir = ROOT_PATH . $this -> images_dir . '/' . $dir . '/';
- } else {
- $dir = $path;
- }
- /* 如果目标目录不存在,则创建它 */
- if (!file_exists($dir)) {
- if (!make_dir($dir)) {
- /* 创建目录失败 */
- $this -> error_msg = sprintf($GLOBALS['_LANG']['directory_readonly'], $dir);
- $this -> error_no = ERR_DIRECTORY_READONLY;
- return false;
- }
- }
- /* 如果文件名为空,生成不重名随机文件名 */
- $filename = $this -> unique_name($dir);
- $filename = !empty($fileName) ? $fileName : $filename;
- /* 生成文件 */
- if (function_exists('imagejpeg')) {
- imagejpeg($img_thumb, $dir . $filename);
- } elseif (function_exists('imagegif')) {
- imagegif($img_thumb, $dir . $filename);
- } elseif (function_exists('imagepng')) {
- imagepng($img_thumb, $dir . $filename);
- } else {
- $this -> error_msg = $GLOBALS['_LANG']['creating_failure'];
- $this -> error_no = ERR_NO_GD;
- return false;
- }
- imagedestroy($img_thumb);
- imagedestroy($img_org);
- //确认文件是否生成
- if (file_exists($dir . $filename)) {
- return str_replace(ROOT_PATH, '', $dir) . $filename;
- } else {
- $this -> error_msg = $GLOBALS['_LANG']['writting_failure'];
- $this -> error_no = ERR_DIRECTORY_READONLY;
- return false;
- }
- }
- /**
- * 为图片增加水印
- *
- * @access public
- * @param string filename 原始图片文件名,包含完整路径
- * @param string target_file 需要加水印的图片文件名,包含完整路径。如果为空则覆盖源文件
- * @param string $watermark 水印完整路径
- * @param int $watermark_place 水印位置代码
- * @return mix 如果成功则返回文件路径,否则返回false
- */
- function add_watermark($filename, $target_file = '', $watermark = '', $watermark_place = '', $watermark_alpha = 0.65) {
- // 是否安装了GD
- $gd = $this -> gd_version();
- if ($gd == 0) {
- $this -> error_msg = $GLOBALS['_LANG']['missing_gd'];
- $this -> error_no = ERR_NO_GD;
- return false;
- }
- // 文件是否存在
- if ((!file_exists($filename)) || (!is_file($filename))) {
- $this -> error_msg = sprintf($GLOBALS['_LANG']['missing_orgin_image'], $filename);
- $this -> error_no = ERR_IMAGE_NOT_EXISTS;
- return false;
- }
- /* 如果水印的位置为0,则返回原图 */
- if ($watermark_place == 0 || empty($watermark)) {
- return str_replace(ROOT_PATH, '', str_replace('\\', '/', realpath($filename)));
- }
- if (!$this -> validate_image($watermark)) {
- /* 已经记录了错误信息 */
- return false;
- }
- // 获得水印文件以及源文件的信息
- $watermark_info = @getimagesize($watermark);
- $watermark_handle = $this -> img_resource($watermark, $watermark_info[2]);
- if (!$watermark_handle) {
- $this -> error_msg = sprintf($GLOBALS['_LANG']['create_watermark_res'], $this -> type_maping[$watermark_info[2]]);
- $this -> error_no = ERR_INVALID_IMAGE;
- return false;
- }
- // 根据文件类型获得原始图片的操作句柄
- $source_info = @getimagesize($filename);
- $source_handle = $this -> img_resource($filename, $source_info[2]);
- if (!$source_handle) {
- $this -> error_msg = sprintf($GLOBALS['_LANG']['create_origin_image_res'], $this -> type_maping[$source_info[2]]);
- $this -> error_no = ERR_INVALID_IMAGE;
- return false;
- }
- // 根据系统设置获得水印的位置
- switch ($watermark_place) {
- case '1' :
- $x = 0;
- $y = 0;
- break;
- case '2' :
- $x = $source_info[0] - $watermark_info[0];
- $y = 0;
- break;
- case '4' :
- $x = 0;
- $y = $source_info[1] - $watermark_info[1];
- break;
- case '5' :
- $x = $source_info[0] - $watermark_info[0];
- $y = $source_info[1] - $watermark_info[1];
- break;
- default :
- $x = $source_info[0] / 2 - $watermark_info[0] / 2;
- $y = $source_info[1] / 2 - $watermark_info[1] / 2;
- }
- if (strpos(strtolower($watermark_info['mime']), 'png') !== false) {
- imageAlphaBlending($watermark_handle, true);
- imagecopy($source_handle, $watermark_handle, $x, $y, 0, 0, $watermark_info[0], $watermark_info[1]);
- } else {
- imagecopymerge($source_handle, $watermark_handle, $x, $y, 0, 0, $watermark_info[0], $watermark_info[1], $watermark_alpha);
- }
- $target = empty($target_file) ? $filename : $target_file;
- switch ($source_info[2] ) {
- case 'image/gif' :
- case 1 :
- imagegif($source_handle, $target);
- break;
- case 'image/pjpeg' :
- case 'image/jpeg' :
- case 2 :
- imagejpeg($source_handle, $target);
- break;
- case 'image/x-png' :
- case 'image/png' :
- case 3 :
- imagepng($source_handle, $target);
- break;
- default :
- $this -> error_msg = $GLOBALS['_LANG']['creating_failure'];
- $this -> error_no = ERR_NO_GD;
- return false;
- }
- imagedestroy($source_handle);
- $path = realpath($target);
- if ($path) {
- return str_replace(ROOT_PATH, '', str_replace('\\', '/', $path));
- } else {
- $this -> error_msg = $GLOBALS['_LANG']['writting_failure'];
- $this -> error_no = ERR_DIRECTORY_READONLY;
- return false;
- }
- }
- /**
- * 检查水印图片是否合法
- *
- * @access public
- * @param string $path 图片路径
- *
- * @return boolen
- */
- function validate_image($path) {
- if (empty($path)) {
- $this -> error_msg = $GLOBALS['_LANG']['empty_watermark'];
- $this -> error_no = ERR_INVALID_PARAM;
- return false;
- }
- /* 文件是否存在 */
- if (!file_exists($path)) {
- $this -> error_msg = sprintf($GLOBALS['_LANG']['missing_watermark'], $path);
- $this -> error_no = ERR_IMAGE_NOT_EXISTS;
- return false;
- }
- // 获得文件以及源文件的信息
- $image_info = @getimagesize($path);
- if (!$image_info) {
- $this -> error_msg = sprintf($GLOBALS['_LANG']['invalid_image_type'], $path);
- $this -> error_no = ERR_INVALID_IMAGE;
- return false;
- }
- /* 检查处理函数是否存在 */
- if (!$this -> check_img_function($image_info[2])) {
- $this -> error_msg = sprintf($GLOBALS['_LANG']['nonsupport_type'], $this -> type_maping[$image_info[2]]);
- $this -> error_no = ERR_NO_GD;
- return false;
- }
- return true;
- }
- /**
- * 返回错误信息
- *
- * @return string 错误信息
- */
- function error_msg() {
- return $this -> error_msg;
- }
- /*------------------------------------------------------ */
- //-- 工具函数
- /*------------------------------------------------------ */
- /**
- * 检查图片类型
- * @param string $img_type 图片类型
- * @return bool
- */
- function check_img_type($img_type) {
- return $img_type == 'image/pjpeg' || $img_type == 'image/x-png' || $img_type == 'image/png' || $img_type == 'image/gif' || $img_type == 'image/jpeg';
- }
- /**
- * 检查图片处理能力
- *
- * @access public
- * @param string $img_type 图片类型
- * @return void
- */
- function check_img_function($img_type) {
- switch ($img_type) {
- case 'image/gif' :
- case 1 :
- if (PHP_VERSION >= '4.3') {
- return function_exists('imagecreatefromgif');
- } else {
- return (imagetypes() & IMG_GIF) > 0;
- }
- break;
- case 'image/pjpeg' :
- case 'image/jpeg' :
- case 2 :
- if (PHP_VERSION >= '4.3') {
- return function_exists('imagecreatefromjpeg');
- } else {
- return (imagetypes() & IMG_JPG) > 0;
- }
- break;
- case 'image/x-png' :
- case 'image/png' :
- case 3 :
- if (PHP_VERSION >= '4.3') {
- return function_exists('imagecreatefrompng');
- } else {
- return (imagetypes() & IMG_PNG) > 0;
- }
- break;
- default :
- return false;
- }
- }
- /**
- * 生成随机的数字串
- *
- * @author: weber liu
- * @return string
- */
- function random_filename() {
- $str = '';
- for ($i = 0; $i < 9; $i++) {
- $str .= mt_rand(0, 9);
- }
- return time() . $str;
- }
- /**
- * 生成指定目录不重名的文件名
- *
- * @access public
- * @param string $dir 要检查是否有同名文件的目录
- *
- * @return string 文件名
- */
- function unique_name($dir) {
- $filename = '';
- while (empty($filename)) {
- $filename = cls_image::random_filename();
- if (file_exists($dir . $filename . '.jpg') || file_exists($dir . $filename . '.gif') || file_exists($dir . $filename . '.png')) {
- $filename = '';
- }
- }
- return $filename;
- }
- /**
- * 返回文件后缀名,如‘.php’
- *
- * @access public
- * @param
- *
- * @return string 文件后缀名
- */
- function get_filetype($path) {
- $pos = strrpos($path, '.');
- if ($pos !== false) {
- return substr($path, $pos);
- } else {
- return '';
- }
- }
- /**
- * 根据来源文件的文件类型创建一个图像操作的标识符
- *
- * @access public
- * @param string $img_file 图片文件的路径
- * @param string $mime_type 图片文件的文件类型
- * @return resource 如果成功则返回图像操作标志符,反之则返回错误代码
- */
- function img_resource($img_file, $mime_type) {
- switch ($mime_type) {
- case 1 :
- case 'image/gif' :
- $res = imagecreatefromgif($img_file);
- break;
- case 2 :
- case 'image/pjpeg' :
- case 'image/jpeg' :
- $res = imagecreatefromjpeg($img_file);
- break;
- case 3 :
- case 'image/x-png' :
- case 'image/png' :
- $res = imagecreatefrompng($img_file);
- break;
- default :
- return false;
- }
- return $res;
- }
- /**
- * 获得服务器上的 GD 版本
- *
- * @access public
- * @return int 可能的值为0,1,2
- */
- function gd_version() {
- static $version = -1;
- if ($version >= 0) {
- return $version;
- }
- if (!extension_loaded('gd')) {
- $version = 0;
- } else {
- // 尝试使用gd_info函数
- if (PHP_VERSION >= '4.3') {
- if (function_exists('gd_info')) {
- $ver_info = gd_info();
- preg_match('/\d/', $ver_info['GD Version'], $match);
- $version = $match[0];
- } else {
- if (function_exists('imagecreatetruecolor')) {
- $version = 2;
- } elseif (function_exists('imagecreate')) {
- $version = 1;
- }
- }
- } else {
- if (preg_match('/phpinfo/', ini_get('disable_functions'))) {
- /* 如果phpinfo被禁用,无法确定gd版本 */
- $version = 1;
- } else {
- // 使用phpinfo函数
- ob_start();
- phpinfo(8);
- $info = ob_get_contents();
- ob_end_clean();
- $info = stristr($info, 'gd version');
- preg_match('/\d/', $info, $match);
- $version = $match[0];
- }
- }
- }
- return $version;
- }
- /**
- *
- *
- * @access public
- * @param
- *
- * @return void
- */
- function move_file($upload, $target) {
- if (isset($upload['error']) && $upload['error'] > 0) {
- return false;
- }
- if (!move_upload_file($upload['tmp_name'], $target)) {
- return false;
- }
- return true;
- }
- }
调用方法:
- try {
- $tempObj = new cls_image();
- } catch (Exception $e) {
- }
- /**
- * 创建图片的缩略图
- *
- * @access public
- * @param string $img 原始图片的路径
- * @param int $thumb_width 缩略图宽度
- * @param int $thumb_height 缩略图高度
- * @param strint $path 指定生成图片的目录名
- * @return mix 如果成功返回缩略图的路径,失败则返回false
- */
- $press_img = $tempObj->make_thumb($file_path,600,0,$save_path,"",$press_file_name);//创建图片的缩略图
- /**
- * 为图片增加水印
- *
- * @access public
- * @param string filename 原始图片文件名,包含完整路径
- * @param string target_file 需要加水印的图片文件名,包含完整路径。如果为空则覆盖源文件
- * @param string $watermark 水印完整路径
- * @param int $watermark_place 水印位置代码
- * @return mix 如果成功则返回文件路径,否则返回false
- */
- $file_path_shuiyin = $tempObj->add_watermark($press0_img , $file_path_shuiyin , $shuiyin_path , 3);
PHP GD 库 缩略图 添加水印的更多相关文章
- php 使用GD库上传图片以及创建缩略图
php 使用GD库上传图片以及创建缩略图 GD库是PHP进行图象操作一个很强大的库. 先在php.ini里增加一行引用:extension=php_gd2.dll 重启apache.做一个测试页 ...
- GD库 图片缩略图 图片水印
/** * GD库 图片缩略图 *//*$image = imagecreatefromjpeg("1.jpg");var_dump($image);exit;$width = i ...
- PHP面向对象——GD库实现图片水印和缩略图
今天的实现目标就是使用GD库完成对图片加水印和图 片缩略图两个功能 动身前逻辑准备 属性: 路径 功能: 构造方法 生成水印的方法 获取 图片信息 获取位置信息(123 456 789) 创建图片资源 ...
- php使用GD库实现图片水印和缩略图——封装成类
学完了如何使用GD库来实现对图片的各种处理,那么我们可以发现,不管哪种方法,都有相似之处,如果我们把这些相似的地方和不相似的地方都封装成类,这样就可以提升代码的速度,而且节省了很多时间,废话不多说,来 ...
- php使用GD库实现图片水印和缩略图——生成图片缩略图
今天呢,就来学习一下在php中使用PD库来实现对图片水印的文字水印方法,不需要PS哦! 首先,准备素材 (1)准备一张图片 (2)准备一张水印(最好是透明的,即背景是白色底) (3)准备一中字体(在电 ...
- php使用GD库实现图片水印和缩略图——给图片添加文字水印
今天呢,就来学习一下在php中使用PD库来实现对图片水印的文字水印方法,不需要PS哦! 首先,准备素材 (1)准备一张图片 (2)准备一张水印(最好是透明的,即背景是白色底) (3)准备一中字体(在电 ...
- GD库的基本信息,图像的旋转、水印、缩略图、验证码,以及图像类的封装
GD库检测 <?php phpinfo(); ?> GD库安装• Windows 使用phpstudy • Linux 编译安装 –with-gd• Linux 编译安装扩展 GD库支持的 ...
- php用GD库给图片添加水印
php用GD库给图片添加文字水印,整个代码比较简单,DEMO如下: <?php /*打开图片*/ //1.配置图片路径 $src = "aeroplane.jpg"; //2 ...
- php使用GD库实现图片水印和缩略图——给图片添加图片水印
今天呢,就来学习一下在php中使用PD库来实现对图片水印的文字水印方法,不需要PS哦! 首先,准备素材 (1)准备一张图片 (2)准备一张水印(最好是透明的,即背景是白色底) (3)准备一中字体(在电 ...
随机推荐
- linux_shell_获取日期相关
shell里直接调用系统变量 获取当天日期`date +%Y%m%d` 获取昨天日期`date -d yesterday +%Y%m%d` 获取前天日期`date -d -2day +%Y%m%d` ...
- iWatch # 初始化工程
iWatch --利用swift,开发iWatch手表小应用! 远程仓库,团队开发: $ git init $ git add . $ git commit -m “ProjectName” // p ...
- Mobile开发的饕餮盛宴-Zoomla!波CMS2 x2.1正式宣布
饕餮 [tāo tiè] 古代汉族神话传说中龙的第五子,是一种存在于传说.想象的神奇怪兽. 古书<山海经>介绍其特点是:其形状如羊身人面,其目在腋下,虎齿人爪.其音如婴儿. 作为中国本土软 ...
- 高效率的Shell
1. 批量将Excel转为CSV文件 XLSX2CSV: https://github.com/dilshod/xlsx2csv sudo easy_install xlsx2csv #安装Xlsx2 ...
- PyCharm 使用简介
PyCharm 使用简介 最近由于项目需要,领导要求使用python以方便扩展,没有办法,赶鸭子上架花了2天时间翻完了python的初级教程然后就开始写代码.有一款好的IDE可以帮助我快速上手一门新语 ...
- The Swift Programming Language-官方教程精译Swift(2)基础知识
Swift 的类型是在 C 和 Objective-C 的基础上提出的,Int是整型:Double和Float是浮点型:Bool是布尔型:String是字符串.Swift 还有两个有用的集合类型,Ar ...
- JVM监控概述(图文)
JVM内存分配概述 Jvm 内存分为:堆.非堆及直接内存三大块. 堆区分为年轻代和老年代,永生代属于非堆内存. 对象优先在Eden区分配 大对象直接进入老年代 长期存活的对象将进入老年代 class. ...
- Serv-U执行CMD命令
site exec + 命令.比如关机: site exec shutdown -r -t 0 注意,网上很多教程在前面加了一个“quote”,实测根本无效,不知道那些教材是怎么回事. 执行方式有很多 ...
- Java 之关键字 null 使用总结
1.null的使用 Java中,null是一个关键字,用来标识一个不确定的对象.因此可以将null赋给引用类型变量,但不可以将null赋给基本类型变量.比如我们在定义一个变量的时候我们通过会这样做:X ...
- lucent检索技术之创建索引:使用POI读取txt/word/excel/ppt/pdf内容
在使用lucent检索文档时,必须先为各文档创建索引.索引的创建即读出文档信息(如文档名称.上传时间.文档内容等),然后再经过分词建索引写入到索引文件里.这里主要是总结下读取各类文档内容这一步. 一. ...