ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ImagickEngine.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 class 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 }