mirror of
https://github.com/Intervention/image.git
synced 2025-08-22 13:32:56 +02:00
Add constants for config options
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
@@ -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());
|
||||
}
|
||||
|
||||
|
@@ -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());
|
||||
}
|
||||
|
||||
|
@@ -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),
|
||||
|
@@ -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());
|
||||
}
|
||||
|
||||
|
@@ -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)
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user