diff --git a/src/Config.php b/src/Config.php index 5b7a4b86..654af169 100644 --- a/src/Config.php +++ b/src/Config.php @@ -9,6 +9,10 @@ use Intervention\Image\Interfaces\ConfigInterface; class Config implements ConfigInterface { + public const AUTO_ORIENTATION = 'autoOrientation'; + public const DECODE_ANIMATION = 'decodeAnimation'; + public const BLENDING_COLOR = 'blendingColor'; + /** * Create config object instance * diff --git a/src/Drivers/Gd/Decoders/BinaryImageDecoder.php b/src/Drivers/Gd/Decoders/BinaryImageDecoder.php index b775eb09..3630753e 100644 --- a/src/Drivers/Gd/Decoders/BinaryImageDecoder.php +++ b/src/Drivers/Gd/Decoders/BinaryImageDecoder.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Drivers\Gd\Decoders; +use Intervention\Image\Config; use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Interfaces\ColorInterface; use Intervention\Image\Interfaces\DecoderInterface; @@ -60,7 +61,7 @@ class BinaryImageDecoder extends NativeObjectDecoder implements DecoderInterface } // adjust image orientation - if ($this->driver()->config()->option('autoOrientation') === true) { + if ($this->driver()->config()->option(Config::AUTO_ORIENTATION) === true) { $image->modify(new AlignRotationModifier()); } diff --git a/src/Drivers/Gd/Decoders/FilePathImageDecoder.php b/src/Drivers/Gd/Decoders/FilePathImageDecoder.php index e3f1780e..f518dcf9 100644 --- a/src/Drivers/Gd/Decoders/FilePathImageDecoder.php +++ b/src/Drivers/Gd/Decoders/FilePathImageDecoder.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Drivers\Gd\Decoders; +use Intervention\Image\Config; use Intervention\Image\Exceptions\DecoderException; use Intervention\Image\Interfaces\ColorInterface; use Intervention\Image\Interfaces\DecoderInterface; @@ -50,7 +51,7 @@ class FilePathImageDecoder extends NativeObjectDecoder implements DecoderInterfa $image->setExif($this->extractExifData($input)); // adjust image orientation - if ($this->driver()->config()->option('autoOrientation') === true) { + if ($this->driver()->config()->option(Config::AUTO_ORIENTATION) === true) { $image->modify(new AlignRotationModifier()); } diff --git a/src/Drivers/Gd/Decoders/NativeObjectDecoder.php b/src/Drivers/Gd/Decoders/NativeObjectDecoder.php index d0e48381..d4edb64b 100644 --- a/src/Drivers/Gd/Decoders/NativeObjectDecoder.php +++ b/src/Drivers/Gd/Decoders/NativeObjectDecoder.php @@ -7,6 +7,7 @@ namespace Intervention\Image\Drivers\Gd\Decoders; use GdImage; use Intervention\Gif\Decoder as GifDecoder; use Intervention\Gif\Splitter as GifSplitter; +use Intervention\Image\Config; use Intervention\Image\Drivers\Gd\Core; use Intervention\Image\Drivers\Gd\Frame; use Intervention\Image\Exceptions\DecoderException; @@ -60,7 +61,7 @@ class NativeObjectDecoder extends AbstractDecoder protected function decodeGif(mixed $input): ImageInterface { // create non-animated image depending on config - if (!$this->driver()->config()->option('decodeAnimation') === true) { + if (!$this->driver()->config()->option(Config::DECODE_ANIMATION) === true) { $native = match (true) { $this->isGifFormat($input) => @imagecreatefromstring($input), default => @imagecreatefromgif($input), diff --git a/src/Drivers/Imagick/Decoders/NativeObjectDecoder.php b/src/Drivers/Imagick/Decoders/NativeObjectDecoder.php index 4c399c7b..cdcb43ab 100644 --- a/src/Drivers/Imagick/Decoders/NativeObjectDecoder.php +++ b/src/Drivers/Imagick/Decoders/NativeObjectDecoder.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Intervention\Image\Drivers\Imagick\Decoders; use Imagick; +use Intervention\Image\Config; use Intervention\Image\Drivers\Imagick\Core; use Intervention\Image\Drivers\SpecializableDecoder; use Intervention\Image\Exceptions\DecoderException; @@ -40,12 +41,12 @@ class NativeObjectDecoder extends SpecializableDecoder ); // discard animation depending on config - if (!$this->driver()->config()->option('decodeAnimation') === true) { + if (!$this->driver()->config()->option(Config::DECODE_ANIMATION) === true) { $image->modify(new RemoveAnimationModifier()); } // adjust image rotatation - if ($this->driver()->config()->option('autoOrientation') === true) { + if ($this->driver()->config()->option(Config::AUTO_ORIENTATION) === true) { $image->modify(new AlignRotationModifier()); } diff --git a/src/Image.php b/src/Image.php index ba02c061..4a6a37b9 100644 --- a/src/Image.php +++ b/src/Image.php @@ -408,7 +408,7 @@ final class Image implements ImageInterface public function blendingColor(): ColorInterface { return $this->driver()->handleInput( - $this->driver()->config()->option('blendingColor') + $this->driver()->config()->option(Config::BLENDING_COLOR) ); } @@ -420,7 +420,7 @@ final class Image implements ImageInterface public function setBlendingColor(mixed $color): ImageInterface { $this->driver()->config()->setOption( - 'blendingColor', + Config::BLENDING_COLOR, $this->driver()->handleInput($color) );