diff --git a/data/config.ini b/data/config.ini index 8ff3aa9b..368cdc66 100644 --- a/data/config.ini +++ b/data/config.ini @@ -108,3 +108,4 @@ categories[] = 'copyright, copyright, #a0a' thumbnailCropStyle = outside customFaviconUrl = /favicon.png dumpSqlIntoQueries = 0 +imageExtension = imagick diff --git a/src/Services/ImageManipulation/ImageManipulator.php b/src/Services/ImageManipulation/ImageManipulator.php index a5ec7481..fd060443 100644 --- a/src/Services/ImageManipulation/ImageManipulator.php +++ b/src/Services/ImageManipulation/ImageManipulator.php @@ -2,6 +2,7 @@ namespace Szurubooru\Services\ImageManipulation; use Szurubooru\Services\ImageManipulation\GdImageManipulator; use Szurubooru\Services\ImageManipulation\ImagickImageManipulator; +use Szurubooru\Config; class ImageManipulator implements IImageManipulator { @@ -9,14 +10,19 @@ class ImageManipulator implements IImageManipulator public function __construct( ImagickImageManipulator $imagickImageManipulator, - GdImageManipulator $gdImageManipulator) + GdImageManipulator $gdImageManipulator, + Config $config) { - if (extension_loaded('imagick')) + if ($config->misc->imageExtension === 'imagick') { + if (!extension_loaded('imagick')) + throw new \RuntimeException('Plugin set to imagick, but not enabled in PHP'); $this->strategy = $imagickImageManipulator; } - else if (extension_loaded('gd')) + else if ($config->misc->imageExtension === 'gd') { + if (!extension_loaded('gd')) + throw new \RuntimeException('Plugin set to gd, but not enabled in PHP'); $this->strategy = $gdImageManipulator; } else