Nextrek
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
<?php
namespace Intervention\Image;
use Closure;
class ImageManager
{
/**
* Config
*
* @var array
*/
public $config = array(
'driver' => 'gd'
);
/**
* Creates new instance of Image Manager
*
* @param array $config
*/
public function __construct(array $config = array())
{
$this->checkRequirements();
$this->configure($config);
}
/**
* Overrides configuration settings
*
* @param array $config
*/
public function configure(array $config = array())
{
$this->config = array_replace($this->config, $config);
return $this;
}
/**
* Initiates an Image instance from different input types
*
* @param mixed $data
*
* @return \Intervention\Image\Image
*/
public function make($data)
{
return $this->createDriver()->init($data);
}
/**
* Creates an empty image canvas
*
* @param integer $width
* @param integer $height
* @param mixed $background
*
* @return \Intervention\Image\Image
*/
public function canvas($width, $height, $background = null)
{
return $this->createDriver()->newImage($width, $height, $background);
}
/**
* Create new cached image and run callback
* (requires additional package intervention/imagecache)
*
* @param Closure $callback
* @param integer $lifetime
* @param boolean $returnObj
*
* @return Image
*/
public function cache(Closure $callback, $lifetime = null, $returnObj = false)
{
if (class_exists('Intervention\\Image\\ImageCache')) {
// create imagecache
$imagecache = new ImageCache($this);
// run callback
if (is_callable($callback)) {
$callback($imagecache);
}
return $imagecache->get($lifetime, $returnObj);
}
throw new \Intervention\Image\Exception\MissingDependencyException(
"Please install package intervention/imagecache before running this function."
);
}
/**
* Creates a driver instance according to config settings
*
* @return \Intervention\Image\AbstractDriver
*/
private function createDriver()
{
$drivername = ucfirst($this->config['driver']);
$driverclass = sprintf('Intervention\\Image\\%s\\Driver', $drivername);
if (class_exists($driverclass)) {
return new $driverclass;
}
throw new \Intervention\Image\Exception\NotSupportedException(
"Driver ({$drivername}) could not be instantiated."
);
}
/**
* Check if all requirements are available
*
* @return void
*/
private function checkRequirements()
{
if ( ! function_exists('finfo_buffer')) {
throw new \Intervention\Image\Exception\MissingDependencyException(
"PHP Fileinfo extension must be installed/enabled to use Intervention Image."
);
}
}
}
|
Revision |
Author |
Commited |
Message |
1464
|
MOliva
|
Tue 13 Oct, 2020 11:16:56 +0000 |
|