You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

56 lines
1.3 KiB

<?php
/**
* 图像处理类
*/
namespace libraries;
class Image {
/**
* 图像文件
* @var string
*/
protected $img;
/**
* 图像驱动
* @var string
*/
protected $driver;
/**
* 驱动对象
* @var array
*/
protected static $objArr = array();
/**
* 构建函数
* @param string $img 图片路径
* @param string $driver 图片驱动
*/
public function __construct($img, $driver = 'gd') {
$this->img = $img;
$this->driver = $driver;
}
/**
* 回调驱动
* @param string $method 回调方法
* @param array $args 回调参数
* @return object
*/
public function __call($method, $args){
if( !isset(self::$objArr[$this->image]) ){
$imageDriver = __NAMESPACE__.'\image\\' . ucfirst( $this->driver ).'Driver';
if( !class_exists($imageDriver) ) {
throw new \Exception("Image Driver '{$imageDriver}' not found'", 500);
}
self::$objArr[$this->image] = new $imageDriver( $this->img );
}
return call_user_func_array(array(self::$objArr[$this->image], $method), $args);
}
}