From 20741c2376eec3eaa9597b4541a55792f4aa7bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BA=A6=E5=BD=93=E8=8B=97=E5=84=BF?= Date: Tue, 16 Apr 2013 11:10:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=A4=84=E7=90=86=E9=A9=B1?= =?UTF-8?q?=E5=8A=A8=E6=8A=9B=E5=87=BA=E5=BC=82=E5=B8=B8=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=91=BD=E5=90=8D=E7=A9=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Library/Think/Image/Driver/Gd.php | 36 +++++++++++++------------- Library/Think/Image/Driver/Gif.php | 2 +- Library/Think/Image/Driver/Imagick.php | 34 ++++++++++++------------ 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Library/Think/Image/Driver/Gd.php b/Library/Think/Image/Driver/Gd.php index 3082b4eb..34facecd 100644 --- a/Library/Think/Image/Driver/Gd.php +++ b/Library/Think/Image/Driver/Gd.php @@ -38,14 +38,14 @@ class Gd{ */ public function open($imgname){ //检测图像文件 - if(!is_file($imgname)) throw new Exception('不存在的图像文件'); + if(!is_file($imgname)) throw new \Exception('不存在的图像文件'); //获取图像信息 $info = getimagesize($imgname); //检测图像合法性 if(false === $info || (IMAGETYPE_GIF === $info[2] && empty($info['bits']))){ - throw new Exception('非法图像文件'); + throw new \Exception('非法图像文件'); } //设置图像信息 @@ -108,7 +108,7 @@ class Gd{ * @return integer 图像宽度 */ public function width(){ - if(empty($this->im)) throw new Exception('没有指定图像资源'); + if(empty($this->im)) throw new \Exception('没有指定图像资源'); return $this->info['width']; } @@ -117,7 +117,7 @@ class Gd{ * @return integer 图像高度 */ public function height(){ - if(empty($this->im)) throw new Exception('没有指定图像资源'); + if(empty($this->im)) throw new \Exception('没有指定图像资源'); return $this->info['height']; } @@ -126,7 +126,7 @@ class Gd{ * @return string 图像类型 */ public function type(){ - if(empty($this->im)) throw new Exception('没有指定图像资源'); + if(empty($this->im)) throw new \Exception('没有指定图像资源'); return $this->info['type']; } @@ -135,7 +135,7 @@ class Gd{ * @return string 图像MIME类型 */ public function mime(){ - if(empty($this->im)) throw new Exception('没有指定图像资源'); + if(empty($this->im)) throw new \Exception('没有指定图像资源'); return $this->info['mime']; } @@ -144,7 +144,7 @@ class Gd{ * @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']]; } @@ -158,7 +158,7 @@ class Gd{ * @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; @@ -191,7 +191,7 @@ class Gd{ * @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']; @@ -286,7 +286,7 @@ class Gd{ break; default: - throw new Exception('不支持的缩略图裁剪类型'); + throw new \Exception('不支持的缩略图裁剪类型'); } /* 裁剪图像 */ @@ -302,13 +302,13 @@ class Gd{ */ 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('水印图像不存在'); //获取水印图像信息 $info = getimagesize($source); if(false === $info || (IMAGETYPE_GIF === $info[2] && empty($info['bits']))){ - throw new Exception('非法水印文件'); + throw new \Exception('非法水印文件'); } //创建水印图像资源 @@ -378,7 +378,7 @@ class Gd{ if(is_array($locate)){ list($x, $y) = $locate; } else { - throw new Exception('不支持的水印位置类型'); + throw new \Exception('不支持的水印位置类型'); } } @@ -415,8 +415,8 @@ class Gd{ 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}"); //获取文字信息 $info = imagettfbbox($size, $angle, $font, $text); @@ -489,7 +489,7 @@ class Gd{ $x += $posx; $y += $posy; } else { - throw new Exception('不支持的文字位置类型'); + throw new \Exception('不支持的文字位置类型'); } } @@ -510,7 +510,7 @@ class Gd{ $color[3] = 0; } } elseif (!is_array($color)) { - throw new Exception('错误的颜色值'); + throw new \Exception('错误的颜色值'); } do{ diff --git a/Library/Think/Image/Driver/Gif.php b/Library/Think/Image/Driver/Gif.php index caa2f6de..5e2b6d69 100644 --- a/Library/Think/Image/Driver/Gif.php +++ b/Library/Think/Image/Driver/Gif.php @@ -41,7 +41,7 @@ class Gif{ $this->frames = $de->GIFGetFrames(); $this->delays = $de->GIFGetDelays(); } catch(Exception $e){ - throw new Exception("解码GIF图片出错"); + throw new \Exception("解码GIF图片出错"); } } } diff --git a/Library/Think/Image/Driver/Imagick.php b/Library/Think/Image/Driver/Imagick.php index 358ba669..85d9b5ef 100644 --- a/Library/Think/Image/Driver/Imagick.php +++ b/Library/Think/Image/Driver/Imagick.php @@ -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('不支持的文字位置类型'); } }