mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-09-02 05:31:36 +08:00
图片处理驱动抛出异常添加命名空间
This commit is contained in:
@@ -41,7 +41,7 @@ class Imagick{
|
||||
*/
|
||||
public function open($imgname){
|
||||
//检测图像文件
|
||||
if(!is_file($imgname)) throw new Exception('不存在的图像文件');
|
||||
if(!is_file($imgname)) throw new \Exception('不存在的图像文件');
|
||||
|
||||
//销毁已存在的图像
|
||||
empty($this->im) || $this->im->destroy();
|
||||
@@ -65,7 +65,7 @@ class Imagick{
|
||||
* @param boolean $interlace 是否对JPEG类型图像设置隔行扫描
|
||||
*/
|
||||
public function save($imgname, $type = null, $interlace = true){
|
||||
if(empty($this->im)) throw new Exception('没有可以被保存的图像资源');
|
||||
if(empty($this->im)) throw new \Exception('没有可以被保存的图像资源');
|
||||
|
||||
//设置图片类型
|
||||
if(is_null($type)){
|
||||
@@ -97,7 +97,7 @@ class Imagick{
|
||||
* @return integer 图像宽度
|
||||
*/
|
||||
public function width(){
|
||||
if(empty($this->im)) throw new Exception('没有指定图像资源');
|
||||
if(empty($this->im)) throw new \Exception('没有指定图像资源');
|
||||
return $this->info['width'];
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ class Imagick{
|
||||
* @return integer 图像高度
|
||||
*/
|
||||
public function height(){
|
||||
if(empty($this->im)) throw new Exception('没有指定图像资源');
|
||||
if(empty($this->im)) throw new \Exception('没有指定图像资源');
|
||||
return $this->info['height'];
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ class Imagick{
|
||||
* @return string 图像类型
|
||||
*/
|
||||
public function type(){
|
||||
if(empty($this->im)) throw new Exception('没有指定图像资源');
|
||||
if(empty($this->im)) throw new \Exception('没有指定图像资源');
|
||||
return $this->info['type'];
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class Imagick{
|
||||
* @return string 图像MIME类型
|
||||
*/
|
||||
public function mime(){
|
||||
if(empty($this->im)) throw new Exception('没有指定图像资源');
|
||||
if(empty($this->im)) throw new \Exception('没有指定图像资源');
|
||||
return $this->info['mime'];
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ class Imagick{
|
||||
* @return array 图像尺寸
|
||||
*/
|
||||
public function size(){
|
||||
if(empty($this->im)) throw new Exception('没有指定图像资源');
|
||||
if(empty($this->im)) throw new \Exception('没有指定图像资源');
|
||||
return [$this->info['width'], $this->info['height']];
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ class Imagick{
|
||||
* @param integer $height 图像保存高度
|
||||
*/
|
||||
public function crop($w, $h, $x = 0, $y = 0, $width = null, $height = null){
|
||||
if(empty($this->im)) throw new Exception('没有可以被裁剪的图像资源');
|
||||
if(empty($this->im)) throw new \Exception('没有可以被裁剪的图像资源');
|
||||
|
||||
//设置保存尺寸
|
||||
empty($width) && $width = $w;
|
||||
@@ -199,7 +199,7 @@ class Imagick{
|
||||
* @param integer $type 缩略图裁剪类型
|
||||
*/
|
||||
public function thumb($width, $height, $type = THINKIMAGE_THUMB_SCALE){
|
||||
if(empty($this->im)) throw new Exception('没有可以被缩略的图像资源');
|
||||
if(empty($this->im)) throw new \Exception('没有可以被缩略的图像资源');
|
||||
|
||||
//原图宽度和高度
|
||||
$w = $this->info['width'];
|
||||
@@ -319,7 +319,7 @@ class Imagick{
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception('不支持的缩略图裁剪类型');
|
||||
throw new \Exception('不支持的缩略图裁剪类型');
|
||||
}
|
||||
|
||||
/* 裁剪图像 */
|
||||
@@ -348,8 +348,8 @@ class Imagick{
|
||||
*/
|
||||
public function water($source, $locate = THINKIMAGE_WATER_SOUTHEAST){
|
||||
//资源检测
|
||||
if(empty($this->im)) throw new Exception('没有可以被添加水印的图像资源');
|
||||
if(!is_file($source)) throw new Exception('水印图像不存在');
|
||||
if(empty($this->im)) throw new \Exception('没有可以被添加水印的图像资源');
|
||||
if(!is_file($source)) throw new \Exception('水印图像不存在');
|
||||
|
||||
//创建水印图像资源
|
||||
$water = new Imagick(realpath($source));
|
||||
@@ -415,7 +415,7 @@ class Imagick{
|
||||
if(is_array($locate)){
|
||||
list($x, $y) = $locate;
|
||||
} else {
|
||||
throw new Exception('不支持的水印位置类型');
|
||||
throw new \Exception('不支持的水印位置类型');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,8 +459,8 @@ class Imagick{
|
||||
public function text($text, $font, $size, $color = '#00000000',
|
||||
$locate = THINKIMAGE_WATER_SOUTHEAST, $offset = 0, $angle = 0){
|
||||
//资源检测
|
||||
if(empty($this->im)) throw new Exception('没有可以被写入文字的图像资源');
|
||||
if(!is_file($font)) throw new Exception("不存在的字体文件:{$font}");
|
||||
if(empty($this->im)) throw new \Exception('没有可以被写入文字的图像资源');
|
||||
if(!is_file($font)) throw new \Exception("不存在的字体文件:{$font}");
|
||||
|
||||
//获取颜色和透明度
|
||||
if(is_array($color)){
|
||||
@@ -470,7 +470,7 @@ class Imagick{
|
||||
}
|
||||
$color = '#' . implode('', $color);
|
||||
} elseif(!is_string($color) || 0 !== strpos($color, '#')) {
|
||||
throw new Exception('错误的颜色值');
|
||||
throw new \Exception('错误的颜色值');
|
||||
}
|
||||
$col = substr($color, 0, 7);
|
||||
$alp = strlen($color) == 9 ? substr($color, -2) : 0;
|
||||
@@ -551,7 +551,7 @@ class Imagick{
|
||||
$x += $posx;
|
||||
$y += $posy;
|
||||
} else {
|
||||
throw new Exception('不支持的文字位置类型');
|
||||
throw new \Exception('不支持的文字位置类型');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user