ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ImagickEngine.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26class ImagickEngine implements Engine
27{
28 use PHPMemoryLimit;
29
31 protected array $whitelist = [
32 'jpg',
33 'jpeg',
34 'gif',
35 'png',
36 'webp',
37 'webm',
38 'tiff',
39 'tif',
40 'bmp',
41 'pdf',
42 'pdf',
43 'svg',
44 ];
46 protected array $supported;
47
48 public function __construct()
49 {
50 $this->supported = array_intersect(
51 array_map(
52 static fn(string $item): string => strtolower($item),
53 $this->isRunning() ? \Imagick::queryFormats() : []
54 ),
55 $this->whitelist
56 );
57 }
58
59 public function supports(string $suffix): bool
60 {
61 return \in_array(strtolower($suffix), $this->supported, true);
62 }
63
64 public function isRunning(): bool
65 {
66 return \extension_loaded('imagick') && class_exists(\Imagick::class);
67 }
68
69}