Added option to set image manipulation extension

This commit is contained in:
rr- 2015-09-06 22:57:28 +02:00
parent 58768acc1c
commit 48bb4fc803
2 changed files with 10 additions and 3 deletions

View file

@ -108,3 +108,4 @@ categories[] = 'copyright, copyright, #a0a'
thumbnailCropStyle = outside thumbnailCropStyle = outside
customFaviconUrl = /favicon.png customFaviconUrl = /favicon.png
dumpSqlIntoQueries = 0 dumpSqlIntoQueries = 0
imageExtension = imagick

View file

@ -2,6 +2,7 @@
namespace Szurubooru\Services\ImageManipulation; namespace Szurubooru\Services\ImageManipulation;
use Szurubooru\Services\ImageManipulation\GdImageManipulator; use Szurubooru\Services\ImageManipulation\GdImageManipulator;
use Szurubooru\Services\ImageManipulation\ImagickImageManipulator; use Szurubooru\Services\ImageManipulation\ImagickImageManipulator;
use Szurubooru\Config;
class ImageManipulator implements IImageManipulator class ImageManipulator implements IImageManipulator
{ {
@ -9,14 +10,19 @@ class ImageManipulator implements IImageManipulator
public function __construct( public function __construct(
ImagickImageManipulator $imagickImageManipulator, 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; $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; $this->strategy = $gdImageManipulator;
} }
else else