25 $this->checkRequirements();
36 $this->config = array_replace($this->config,
$config);
48 public function make($data)
50 return $this->createDriver()->init($data);
62 public function canvas($width, $height, $background =
null)
64 return $this->createDriver()->newImage($width, $height, $background);
77 public function cache(Closure $callback, $lifetime =
null, $returnObj =
false)
79 if (class_exists(
'Intervention\\Image\\ImageCache')) {
81 $imagecache =
new ImageCache($this);
84 if (is_callable($callback)) {
85 $callback($imagecache);
88 return $imagecache->get($lifetime, $returnObj);
91 throw new \Intervention\Image\Exception\MissingDependencyException(
92 "Please install package intervention/imagecache before running this function."
101 private function createDriver()
103 $drivername = ucfirst($this->config[
'driver']);
104 $driverclass = sprintf(
'Intervention\\Image\\%s\\Driver', $drivername);
106 if (class_exists($driverclass)) {
107 return new $driverclass;
110 throw new \Intervention\Image\Exception\NotSupportedException(
111 "Driver ({$drivername}) could not be instantiated."
120 private function checkRequirements()
122 if ( ! function_exists(
'finfo_buffer')) {
123 throw new \Intervention\Image\Exception\MissingDependencyException(
124 "PHP Fileinfo extension must be installed/enabled to use Intervention Image."