//使用UTF-8
/**
* Module: Image Class Module v1.2
*
* author: leaf
* email:yuyuyezi@vip.qq
* time: 2012-02-16 14:55
* last_modify-time: 2012-04-19 14:47
* copyright: All Free
*
* functions:
* 1.thumb *
* 2.water mark
* 3.cutPart size
* 4.format convert
* 5.cut border *
* 6.gamma(new)
* 7.gaussPart(new)
* 8.gauss (new)
*/
/*
1、本空间源码部分原创,部分为
网络分享。
原创部分源码可以任意使用,但作者保留个人
版权。 2、大多数情况下,代码已经作者有限的检测和调试,但这不代表代码中一定就不包含错误。您可以自己选择将其用于其它用途,但因此造成的任何后果都与作者无责。
3、如果发现错误,或有更好的建议,请先系作者:yuyuyezi@vip.qq。(QQ:910657702)
4、转载请注明出处,以便跟踪其它用户的bug提交。举手之劳,方便大家,谢谢合作!
此代码的详细的使用方法及示例,请访问作者空间。hi.baidu/zhangshe
*/
//import('leaf.image.RGB'); //导入RGB类
//require_once "RGB.class.php";//导入RGB类
define('SAMPLE_DENSITY',30);//像素点采样精度(每个指定像素采样比对一次)数值越大越精细,但处理也会更耗时
define('CM_LEVAL',20); //颜色匹配级别 color match leval(0-255)
define('CMT_LEVAL',0.9); //匹配次数级别 count match leval(0.1-1)
define('RED_INDEX', 0); //颜色索引
define('GREEN_INDEX', 1); //颜色索引
define('BLUE_INDEX', 2); //颜色索引
define('GAUSS_BLOCK_SIZE',100); //Gauss模糊处理块边大小,一次读取块越小,占用内存越小,同时块数会增加
define('SUPORT_MIME',"JPG,PNG,GIF");//支持的文件类型
define('JPEG_SAVE_QUALITY',80); //JPEG图片保存的质量(0-100)
//RGB Class
class RGB{
private $red= 0; //红绿蓝索引
private $green= 0;
private $blue= 0;
/**
* __construct
*
* @param mix $rgb
*/
function __construct($rgb= null){
$args_array=func_get_args();
if(func_num_args() == 1){
$this->setValue($rgb);
}else if(func_num_args() == 3){
$this->setRed($args_array[0]);
$this->setGreen($args_array[1]);
$this->setBlue($args_array[2]);
}
}
/**
* 设置值
*
* @param mix $rgb
*/
function setValue($rgb){
if($rgb == null){
$this->red= 0;
$this->green= 0;
$this->blue= 0;
}else if(is_array($rgb) &;&; count($rgb) >= 3){
if(isset($rgb['red']) &;&; isset($rgb['green']) &;&; isset($rgb['blue'])){
$this->setRed($rgb['red']);
$this->setGreen($rgb['green']);
$this->setBlue($rgb['blue']);
}elseif(isset($rgb[0]) &;&; isset($rgb[1]) &;&; isset($rgb[2])){
$this->setRed($rgb[0]);
$this->setGreen($rgb[1]);
$this->setBlue($rgb[2]);
}else{
exit('unable rgb setValue source');
}
}else if(is_object($rgb) &;&; get_class($rgb) =
= 'RGB'){
$this->setRed($rgb->getRed());
$this->setGreen($rgb->getGreen());
$this->setBlue($rgb->getBlue());
}else{
print_r($rgb);
exit('unable rgb setValue source');
}
}
/**
* __destruct
*
*/
function __destruct(){
//do nothing.
}
/**
* 设置颜色索引
*
* @param int $red
* @return int 返回设置的颜色索引
*/
function setRed($red){
$this->red= abs(intval($red));
if($this->red > 255){
$this->red= 255;
}
return $this->red;
}
/**
* 设置颜色索引
*
* @param int $red
* @return int 返回设置的颜色索引
*/
function setGreen($green){
$this->green= abs(intval($green));
if($this->green >255 ){
$this->green= 255;
}
return $this-