diff --git a/src/Config.php b/src/Config.php new file mode 100644 index 00000000..aec6d346 --- /dev/null +++ b/src/Config.php @@ -0,0 +1,32 @@ +decodeAnimation; + } + + public function autoOrientate(): bool + { + return $this->autoOrientate; + } + + public function blendingColor(): mixed + { + return $this->blendingColor; + } +} diff --git a/src/Drivers/AbstractDriver.php b/src/Drivers/AbstractDriver.php index 62c76817..abfe9bf0 100644 --- a/src/Drivers/AbstractDriver.php +++ b/src/Drivers/AbstractDriver.php @@ -4,11 +4,13 @@ declare(strict_types=1); namespace Intervention\Image\Drivers; +use Intervention\Image\Config; use Intervention\Image\Exceptions\DriverException; use Intervention\Image\Exceptions\NotSupportedException; use Intervention\Image\InputHandler; use Intervention\Image\Interfaces\AnalyzerInterface; use Intervention\Image\Interfaces\ColorInterface; +use Intervention\Image\Interfaces\ConfigInterface; use Intervention\Image\Interfaces\DecoderInterface; use Intervention\Image\Interfaces\DriverInterface; use Intervention\Image\Interfaces\EncoderInterface; @@ -21,13 +23,25 @@ use ReflectionClass; abstract class AbstractDriver implements DriverInterface { /** + * @param ConfigInterface $config * @throws DriverException + * @return void */ - public function __construct() + public function __construct(protected ConfigInterface $config = new Config()) { $this->checkHealth(); } + /** + * {@inheritdoc} + * + * @see DriverInterface::config() + */ + public function config(): ConfigInterface + { + return $this->config; + } + /** * {@inheritdoc} * diff --git a/src/ImageManager.php b/src/ImageManager.php index 383dea5f..4f8ca7c1 100644 --- a/src/ImageManager.php +++ b/src/ImageManager.php @@ -40,22 +40,24 @@ final class ImageManager implements ImageManagerInterface * Create image manager with GD driver * * @link https://image.intervention.io/v3/basics/image-manager#static-gd-driver-constructor + * @param mixed $options * @return ImageManager */ - public static function gd(): self + public static function gd(mixed ...$options): self { - return self::withDriver(GdDriver::class); + return self::withDriver(new GdDriver(new Config(...$options))); } /** * Create image manager with Imagick driver * * @link https://image.intervention.io/v3/basics/image-manager#static-imagick-driver-constructor + * @param mixed $options * @return ImageManager */ - public static function imagick(): self + public static function imagick(mixed ...$options): self { - return self::withDriver(ImagickDriver::class); + return self::withDriver(new ImagickDriver(new Config(...$options))); } /** diff --git a/src/Interfaces/ConfigInterface.php b/src/Interfaces/ConfigInterface.php new file mode 100644 index 00000000..27ceda9c --- /dev/null +++ b/src/Interfaces/ConfigInterface.php @@ -0,0 +1,12 @@ +