1 | <?php |
||
7 | class Conversion |
||
8 | { |
||
9 | /** |
||
10 | * @var string name |
||
11 | */ |
||
12 | protected $name = ''; |
||
13 | |||
14 | /** |
||
15 | * @var int |
||
16 | */ |
||
17 | protected $extractVideoFrameAtSecond = 0; |
||
18 | |||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $manipulations = []; |
||
23 | |||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | protected $performOnCollections = []; |
||
28 | |||
29 | /** |
||
30 | * @var bool |
||
31 | */ |
||
32 | protected $performOnQueue = true; |
||
33 | |||
34 | public function __construct(string $name) |
||
38 | |||
39 | public static function create(string $name) |
||
43 | |||
44 | public function getName() : string |
||
48 | |||
49 | /* |
||
50 | * Set the timecode in seconds to extract a video thumbnail. |
||
51 | * Only used on video media. |
||
52 | */ |
||
53 | public function setExtractVideoFrameAtSecond(int $timecode) : Conversion |
||
54 | { |
||
55 | $this->extractVideoFrameAtSecond = $timecode; |
||
56 | |||
57 | return $this; |
||
58 | } |
||
59 | |||
60 | public function getExtractVideoFrameAtSecond(): int |
||
61 | { |
||
62 | return $this->extractVideoFrameAtSecond; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Get the manipulations of this conversion. |
||
67 | */ |
||
68 | public function getManipulations() : array |
||
79 | |||
80 | /** |
||
81 | * Set the manipulations for this conversion. |
||
82 | * |
||
83 | * @param $manipulations |
||
84 | * |
||
85 | * @return $this |
||
86 | */ |
||
87 | public function setManipulations(...$manipulations) |
||
93 | |||
94 | /** |
||
95 | * Add the given manipulation as the first manipulation. |
||
96 | * |
||
97 | * @param array $manipulation |
||
98 | * |
||
99 | * @return $this |
||
100 | */ |
||
101 | public function addAsFirstManipulation(array $manipulation) |
||
107 | |||
108 | /** |
||
109 | * Set the collection names on which this conversion must be performed. |
||
110 | * |
||
111 | * @param array $collectionNames |
||
112 | * |
||
113 | * @return $this |
||
114 | */ |
||
115 | public function performOnCollections(...$collectionNames) |
||
121 | |||
122 | /* |
||
123 | * Determine if this conversion should be performed on the given |
||
124 | * collection. |
||
125 | */ |
||
126 | public function shouldBePerformedOn(string $collectionName) : bool |
||
139 | |||
140 | /** |
||
141 | * Mark this conversion as one that should be queued. |
||
142 | * |
||
143 | * @return $this |
||
144 | */ |
||
145 | public function queued() |
||
151 | |||
152 | /** |
||
153 | * Mark this conversion as one that should not be queued. |
||
154 | * |
||
155 | * @return $this |
||
156 | */ |
||
157 | public function nonQueued() |
||
163 | |||
164 | /* |
||
165 | * Determine if the conversion should be queued. |
||
166 | */ |
||
167 | public function shouldBeQueued() : bool |
||
171 | |||
172 | /* |
||
173 | * Get the extension that the result of this conversion must have. |
||
174 | */ |
||
175 | public function getResultExtension(string $originalFileExtension = '') : string |
||
189 | |||
190 | /* |
||
191 | * Determine if the given manipulations contain a format manipulation. |
||
192 | */ |
||
193 | protected function containsFormatManipulation(array $manipulations) : bool |
||
203 | |||
204 | /** |
||
205 | * Set the target width. |
||
206 | * Matches with Glide's 'w'-parameter. |
||
207 | * |
||
208 | * @param int $width |
||
209 | * |
||
210 | * @return $this |
||
211 | * |
||
212 | * @throws \Spatie\MediaLibrary\Exceptions\InvalidConversionParameter |
||
213 | */ |
||
214 | public function setWidth(int $width) |
||
224 | |||
225 | /** |
||
226 | * Set the target height. |
||
227 | * Matches with Glide's 'h'-parameter. |
||
228 | * |
||
229 | * @param int $height |
||
230 | * |
||
231 | * @return $this |
||
232 | * |
||
233 | * @throws \Spatie\MediaLibrary\Exceptions\InvalidConversionParameter |
||
234 | */ |
||
235 | public function setHeight(int $height) |
||
245 | |||
246 | /** |
||
247 | * Set the target format. |
||
248 | * Matches with Glide's 'fm'-parameter. |
||
249 | * |
||
250 | * @param string $format |
||
251 | * |
||
252 | * @return $this |
||
253 | * |
||
254 | * @throws \Spatie\MediaLibrary\Exceptions\InvalidConversionParameter |
||
255 | */ |
||
256 | public function setFormat(string $format) |
||
268 | |||
269 | /** |
||
270 | * Set the target fit. |
||
271 | * Matches with Glide's 'fit'-parameter. |
||
272 | * |
||
273 | * @param string $fit |
||
274 | * |
||
275 | * @return $this |
||
276 | * |
||
277 | * @throws \Spatie\MediaLibrary\Exceptions\InvalidConversionParameter |
||
278 | */ |
||
279 | public function setFit(string $fit) |
||
306 | |||
307 | /** |
||
308 | * Crops the image to specific dimensions prior to any other resize operations. |
||
309 | * |
||
310 | * @param int $width |
||
311 | * @param int $height |
||
312 | * @param int $x |
||
313 | * @param int $y |
||
314 | * |
||
315 | * @return $this |
||
316 | * |
||
317 | * @throws \Spatie\MediaLibrary\Exceptions\InvalidConversionParameter |
||
318 | */ |
||
319 | public function setCrop(int $width, int $height, int $x, int $y) |
||
331 | |||
332 | /** |
||
333 | * Set the manipulation parameter. |
||
334 | * |
||
335 | * @param string $name |
||
336 | * @param string $value |
||
337 | * |
||
338 | * @return $this |
||
339 | */ |
||
340 | public function setManipulationParameter(string $name, string $value) |
||
348 | } |
||
349 |