diff --git a/src/Drivers/Concerns/PerformsOptimizations.php b/src/Drivers/Concerns/PerformsOptimizations.php index 4984a5ef..09dedd39 100644 --- a/src/Drivers/Concerns/PerformsOptimizations.php +++ b/src/Drivers/Concerns/PerformsOptimizations.php @@ -11,7 +11,7 @@ trait PerformsOptimizations protected OptimizerChain $optimizerChain; - public function optimize(?OptimizerChain $optimizerChain = null): self + public function optimize(?OptimizerChain $optimizerChain = null): static { $this->optimize = true; $this->optimizerChain = $optimizerChain ?? OptimizerChainFactory::create(); diff --git a/src/Drivers/Gd/GdDriver.php b/src/Drivers/Gd/GdDriver.php index 950f098b..ea6cde7f 100644 --- a/src/Drivers/Gd/GdDriver.php +++ b/src/Drivers/Gd/GdDriver.php @@ -38,7 +38,7 @@ class GdDriver implements ImageDriver protected string $originalPath; - public function new(int $width, int $height, ?string $backgroundColor = null): self + public function new(int $width, int $height, ?string $backgroundColor = null): static { $image = imagecreatetruecolor($width, $height); @@ -49,14 +49,14 @@ public function new(int $width, int $height, ?string $backgroundColor = null): s return (new self)->setImage($image); } - protected function setImage(GdImage $image): self + protected function setImage(GdImage $image): static { $this->image = $image; return $this; } - public function loadFile(string $path): self + public function loadFile(string $path): static { $this->optimize = false; $this->quality = -1; @@ -99,7 +99,7 @@ public function getHeight(): int return imagesy($this->image); } - public function brightness(int $brightness): self + public function brightness(int $brightness): static { // TODO: Convert value between -100 and 100 to -255 and 255 $brightness = round($brightness * 2.55); @@ -109,7 +109,7 @@ public function brightness(int $brightness): self return $this; } - public function blur(int $blur): self + public function blur(int $blur): static { for ($i = 0; $i < $blur; $i++) { imagefilter($this->image, IMG_FILTER_GAUSSIAN_BLUR); @@ -118,7 +118,7 @@ public function blur(int $blur): self return $this; } - public function save(?string $path = null): self + public function save(?string $path = null): static { if (! $path) { $path = $this->originalPath; @@ -177,7 +177,7 @@ public function getSize(): Size return new Size($this->getWidth(), $this->getHeight()); } - public function fit(Fit $fit, ?int $desiredWidth = null, ?int $desiredHeight = null): self + public function fit(Fit $fit, ?int $desiredWidth = null, ?int $desiredHeight = null): static { $calculatedSize = $fit->calculateSize( $this->getWidth(), @@ -209,7 +209,7 @@ protected function modify( int $sourceY = 0, int $sourceWidth = 0, int $sourceHeight = 0, - ): self { + ): static { $newImage = imagecreatetruecolor($desiredWidth, $desiredHeight); $transparentColorValue = imagecolortransparent($this->image); @@ -269,7 +269,7 @@ public function resizeCanvas( ?AlignPosition $position = null, bool $relative = false, string $backgroundColor = '#ffffff' - ): self { + ): static { $position ??= AlignPosition::Center; $originalWidth = $this->getWidth(); @@ -331,21 +331,21 @@ public function resizeCanvas( return $this; } - public function gamma(float $gamma): self + public function gamma(float $gamma): static { imagegammacorrect($this->image, 1, $gamma); return $this; } - public function contrast(float $level): self + public function contrast(float $level): static { imagefilter($this->image, IMG_FILTER_CONTRAST, ($level * -1)); return $this; } - public function colorize(int $red, int $green, int $blue): self + public function colorize(int $red, int $green, int $blue): static { $red = round($red * 2.55); $green = round($green * 2.55); @@ -356,14 +356,14 @@ public function colorize(int $red, int $green, int $blue): self return $this; } - public function greyscale(): self + public function greyscale(): static { imagefilter($this->image, IMG_FILTER_GRAYSCALE); return $this; } - public function manualCrop(int $width, int $height, ?int $x = null, ?int $y = null): self + public function manualCrop(int $width, int $height, ?int $x = null, ?int $y = null): static { $cropped = new Size($width, $height); $position = new Point($x ?? 0, $y ?? 0); @@ -393,7 +393,7 @@ public function manualCrop(int $width, int $height, ?int $x = null, ?int $y = nu return $this; } - public function crop(int $width, int $height, CropPosition $position = CropPosition::Center): self + public function crop(int $width, int $height, CropPosition $position = CropPosition::Center): static { $width = min($width, $this->getWidth()); $height = min($height, $this->getHeight()); @@ -408,7 +408,7 @@ public function crop(int $width, int $height, CropPosition $position = CropPosit return $this->manualCrop($width, $height, $offsetX, $offsetY); } - public function focalCrop(int $width, int $height, ?int $cropCenterX = null, ?int $cropCenterY = null): self + public function focalCrop(int $width, int $height, ?int $cropCenterX = null, ?int $cropCenterY = null): static { [$width, $height, $cropCenterX, $cropCenterY] = $this->calculateFocalCropCoordinates( $width, @@ -422,7 +422,7 @@ public function focalCrop(int $width, int $height, ?int $cropCenterX = null, ?in return $this; } - public function sepia(): ImageDriver + public function sepia(): static { return $this ->greyscale() @@ -432,7 +432,7 @@ public function sepia(): ImageDriver ->contrast(5); } - public function sharpen(float $amount): self + public function sharpen(float $amount): static { $min = $amount >= 10 ? $amount * -0.01 : 0; $max = $amount * -0.025; @@ -449,7 +449,7 @@ public function sharpen(float $amount): self return $this; } - public function background(string $color): self + public function background(string $color): static { $width = $this->getWidth(); $height = $this->getHeight(); @@ -465,7 +465,7 @@ public function background(string $color): self return $this; } - public function overlay(ImageDriver $bottomImage, ImageDriver $topImage, int $x = 0, int $y = 0): self + public function overlay(ImageDriver $bottomImage, ImageDriver $topImage, int $x = 0, int $y = 0): static { $bottomImage->insert($topImage, AlignPosition::TopLeft, $x, $y); $this->image = $bottomImage->image(); @@ -473,7 +473,7 @@ public function overlay(ImageDriver $bottomImage, ImageDriver $topImage, int $x return $this; } - public function orientation(?Orientation $orientation = null): self + public function orientation(?Orientation $orientation = null): static { if (is_null($orientation)) { $orientation = $this->getOrientationFromExif($this->exif); @@ -504,7 +504,7 @@ public function exif(): array return $this->exif; } - public function flip(FlipDirection $flip): self + public function flip(FlipDirection $flip): static { $direction = match ($flip) { FlipDirection::Horizontal => IMG_FLIP_HORIZONTAL, @@ -517,7 +517,7 @@ public function flip(FlipDirection $flip): self return $this; } - public function pixelate(int $pixelate = 50): self + public function pixelate(int $pixelate = 50): static { imagefilter($this->image, IMG_FILTER_PIXELATE, $pixelate, true); @@ -529,7 +529,7 @@ public function insert( AlignPosition $position = AlignPosition::Center, int $x = 0, int $y = 0, - ): self { + ): static { if (is_string($otherImage)) { $otherImage = (new self())->loadFile($otherImage); } @@ -554,7 +554,7 @@ public function insert( return $this; } - public function resize(int $width, int $height, array $constraints = []): self + public function resize(int $width, int $height, array $constraints = []): static { $resized = $this->getSize()->resize($width, $height, $constraints); @@ -563,21 +563,21 @@ public function resize(int $width, int $height, array $constraints = []): self return $this; } - public function width(int $width, array $constraints = [Constraint::PreserveAspectRatio]): self + public function width(int $width, array $constraints = [Constraint::PreserveAspectRatio]): static { $this->resize($width, $this->getHeight(), $constraints); return $this; } - public function height(int $height, array $constraints = [Constraint::PreserveAspectRatio]): self + public function height(int $height, array $constraints = [Constraint::PreserveAspectRatio]): static { $this->resize($this->getWidth(), $height, $constraints); return $this; } - public function border(int $width, BorderType $type, string $color = '000000'): self + public function border(int $width, BorderType $type, string $color = '000000'): static { if ($type === BorderType::Shrink) { $originalWidth = $this->getWidth(); @@ -644,7 +644,7 @@ public function border(int $width, BorderType $type, string $color = '000000'): } /** @param int<-1, 100> $quality */ - public function quality(int $quality): self + public function quality(int $quality): static { $this->quality = $quality; @@ -661,7 +661,7 @@ protected function pngCompression(): int return (int) round((100 - $this->quality) / 10); } - public function format(string $format): ImageDriver + public function format(string $format): static { ob_start(); diff --git a/src/Drivers/ImageDriver.php b/src/Drivers/ImageDriver.php index 17a660a5..b6f281c0 100644 --- a/src/Drivers/ImageDriver.php +++ b/src/Drivers/ImageDriver.php @@ -15,11 +15,11 @@ interface ImageDriver { - public function new(int $width, int $height, ?string $backgroundColor = null): self; + public function new(int $width, int $height, ?string $backgroundColor = null): static; public function driverName(): string; - public function save(string $path = ''): self; + public function save(string $path = ''): static; public function getWidth(): int; @@ -28,28 +28,28 @@ public function getHeight(): int; /** * @param int $brightness A value between -100 and 100 */ - public function brightness(int $brightness): self; + public function brightness(int $brightness): static; - public function gamma(float $gamma): self; + public function gamma(float $gamma): static; - public function contrast(float $level): self; + public function contrast(float $level): static; /** * @param int $blur A value between 0 and 100. */ - public function blur(int $blur): self; + public function blur(int $blur): static; - public function colorize(int $red, int $green, int $blue): self; + public function colorize(int $red, int $green, int $blue): static; - public function greyscale(): self; + public function greyscale(): static; - public function sepia(): self; + public function sepia(): static; - public function sharpen(float $amount): self; + public function sharpen(float $amount): static; public function getSize(): Size; - public function fit(Fit $fit, ?int $desiredWidth = null, ?int $desiredHeight = null): self; + public function fit(Fit $fit, ?int $desiredWidth = null, ?int $desiredHeight = null): static; public function pickColor(int $x, int $y, ColorFormat $colorFormat): mixed; @@ -59,51 +59,51 @@ public function resizeCanvas( ?AlignPosition $position = null, bool $relative = false, string $backgroundColor = '#000000' - ): self; + ): static; - public function manualCrop(int $width, int $height, int $x = 0, int $y = 0): self; + public function manualCrop(int $width, int $height, int $x = 0, int $y = 0): static; - public function crop(int $width, int $height, CropPosition $position = CropPosition::Center): self; + public function crop(int $width, int $height, CropPosition $position = CropPosition::Center): static; - public function focalCrop(int $width, int $height, ?int $cropCenterX = null, ?int $cropCenterY = null): self; + public function focalCrop(int $width, int $height, ?int $cropCenterX = null, ?int $cropCenterY = null): static; public function base64(string $imageFormat): string; - public function background(string $color): self; + public function background(string $color): static; - public function overlay(ImageDriver $bottomImage, ImageDriver $topImage, int $x, int $y): self; + public function overlay(ImageDriver $bottomImage, ImageDriver $topImage, int $x, int $y): static; - public function orientation(?Orientation $orientation = null): self; + public function orientation(?Orientation $orientation = null): static; public function exif(): array; - public function flip(FlipDirection $flip): self; + public function flip(FlipDirection $flip): static; - public function pixelate(int $pixelate): self; + public function pixelate(int $pixelate): static; public function insert( ImageDriver|string $otherImage, AlignPosition $position = AlignPosition::Center, int $x = 0, int $y = 0, - ): self; + ): static; public function image(): mixed; /** @param array $constraints */ - public function resize(int $width, int $height, array $constraints): self; + public function resize(int $width, int $height, array $constraints): static; /** @param array $constraints */ - public function width(int $width, array $constraints = []): self; + public function width(int $width, array $constraints = []): static; /** @param array $constraints */ - public function height(int $height, array $constraints = []): self; + public function height(int $height, array $constraints = []): static; - public function border(int $width, BorderType $type, string $color = '000000'): self; + public function border(int $width, BorderType $type, string $color = '000000'): static; - public function quality(int $quality): self; + public function quality(int $quality): static; - public function format(string $format): self; + public function format(string $format): static; - public function optimize(?OptimizerChain $optimizerChain = null): self; + public function optimize(?OptimizerChain $optimizerChain = null): static; } diff --git a/src/Drivers/Imagick/ImagickDriver.php b/src/Drivers/Imagick/ImagickDriver.php index 80981d08..1f056907 100644 --- a/src/Drivers/Imagick/ImagickDriver.php +++ b/src/Drivers/Imagick/ImagickDriver.php @@ -37,7 +37,7 @@ class ImagickDriver implements ImageDriver protected string $originalPath; - public function new(int $width, int $height, ?string $backgroundColor = null): self + public function new(int $width, int $height, ?string $backgroundColor = null): static { $color = new ImagickColor($backgroundColor); $image = new Imagick(); @@ -50,7 +50,7 @@ public function new(int $width, int $height, ?string $backgroundColor = null): s return (new self())->setImage($image); } - protected function setImage(Imagick $image): self + protected function setImage(Imagick $image): static { $this->image = $image; @@ -62,7 +62,7 @@ public function image(): Imagick return $this->image; } - public function loadFile(string $path): self + public function loadFile(string $path): static { $this->originalPath = $path; @@ -84,21 +84,21 @@ public function getHeight(): int return $this->image->getImageHeight(); } - public function brightness(int $brightness): self + public function brightness(int $brightness): static { $this->image->modulateImage(100 + $brightness, 100, 100); return $this; } - public function blur(int $blur): self + public function blur(int $blur): static { $this->image->blurImage(0.5 * $blur, 0.1 * $blur); return $this; } - public function fit(Fit $fit, ?int $desiredWidth = null, ?int $desiredHeight = null): self + public function fit(Fit $fit, ?int $desiredWidth = null, ?int $desiredHeight = null): static { $calculatedSize = $fit->calculateSize( $this->getWidth(), @@ -122,7 +122,7 @@ public function resizeCanvas( ?AlignPosition $position = null, bool $relative = false, ?string $backgroundColor = null - ): self { + ): static { $position ??= AlignPosition::Center; $originalWidth = $this->getWidth(); @@ -201,7 +201,7 @@ public function pickColor(int $x, int $y, ColorFormat $colorFormat): mixed return $color->format($colorFormat); } - public function save(?string $path = null): ImageDriver + public function save(?string $path = null): static { if (! $path) { $path = $this->originalPath; @@ -244,21 +244,21 @@ public function getSize(): Size return new Size($this->getWidth(), $this->getHeight()); } - public function gamma(float $gamma): self + public function gamma(float $gamma): static { $this->image->gammaImage($gamma); return $this; } - public function contrast(float $level): self + public function contrast(float $level): static { $this->image->brightnessContrastImage(1, $level); return $this; } - public function colorize(int $red, int $green, int $blue): self + public function colorize(int $red, int $green, int $blue): static { $quantumRange = $this->image->getQuantumRange(); @@ -273,14 +273,14 @@ public function colorize(int $red, int $green, int $blue): self return $this; } - public function greyscale(): self + public function greyscale(): static { $this->image->modulateImage(100, 0, 100); return $this; } - public function manualCrop(int $width, int $height, ?int $x = null, ?int $y = null): self + public function manualCrop(int $width, int $height, ?int $x = null, ?int $y = null): static { $cropped = new Size($width, $height); $position = new Point($x ?? 0, $y ?? 0); @@ -298,14 +298,14 @@ public function manualCrop(int $width, int $height, ?int $x = null, ?int $y = nu return $this; } - public function crop(int $width, int $height, CropPosition $position = CropPosition::Center): self + public function crop(int $width, int $height, CropPosition $position = CropPosition::Center): static { [$offsetX, $offsetY] = $this->calculateCropOffsets($width, $height, $position); return $this->manualCrop($width, $height, $offsetX, $offsetY); } - public function focalCrop(int $width, int $height, ?int $cropCenterX = null, ?int $cropCenterY = null): self + public function focalCrop(int $width, int $height, ?int $cropCenterX = null, ?int $cropCenterY = null): static { [$width, $height, $cropCenterX, $cropCenterY] = $this->calculateFocalCropCoordinates( $width, @@ -319,7 +319,7 @@ public function focalCrop(int $width, int $height, ?int $cropCenterX = null, ?in return $this; } - public function sepia(): ImageDriver + public function sepia(): static { return $this ->greyscale() @@ -330,14 +330,14 @@ public function sepia(): ImageDriver ->contrast(10); } - public function sharpen(float $amount): self + public function sharpen(float $amount): static { $this->image->unsharpMaskImage(1, 1, $amount / 6.25, 0); return $this; } - public function background(string $color): self + public function background(string $color): static { $background = $this->new($this->getWidth(), $this->getHeight(), $color); @@ -346,7 +346,7 @@ public function background(string $color): self return $this; } - public function overlay(ImageDriver $bottomImage, ImageDriver $topImage, int $x = 0, int $y = 0): self + public function overlay(ImageDriver $bottomImage, ImageDriver $topImage, int $x = 0, int $y = 0): static { $bottomImage->insert($topImage, AlignPosition::Center, $x, $y); $this->image = $bottomImage->image(); @@ -354,7 +354,7 @@ public function overlay(ImageDriver $bottomImage, ImageDriver $topImage, int $x return $this; } - public function orientation(?Orientation $orientation = null): self + public function orientation(?Orientation $orientation = null): static { if (is_null($orientation)) { $orientation = $this->getOrientationFromExif($this->exif); @@ -370,7 +370,7 @@ public function exif(): array return $this->exif; } - public function flip(FlipDirection $flip): self + public function flip(FlipDirection $flip): static { switch ($flip) { case FlipDirection::Vertical: @@ -388,7 +388,7 @@ public function flip(FlipDirection $flip): self return $this; } - public function pixelate(int $pixelate = 50): self + public function pixelate(int $pixelate = 50): static { $width = $this->getWidth(); $height = $this->getHeight(); @@ -404,7 +404,7 @@ public function insert( AlignPosition $position = AlignPosition::Center, int $x = 0, int $y = 0, - ): self { + ): static { if (is_string($otherImage)) { $otherImage = (new self())->loadFile($otherImage); } @@ -425,7 +425,7 @@ public function insert( return $this; } - public function resize(int $width, int $height, array $constraints = []): self + public function resize(int $width, int $height, array $constraints = []): static { $resized = $this->getSize()->resize($width, $height, $constraints); @@ -434,21 +434,21 @@ public function resize(int $width, int $height, array $constraints = []): self return $this; } - public function width(int $width, array $constraints = [Constraint::PreserveAspectRatio]): self + public function width(int $width, array $constraints = [Constraint::PreserveAspectRatio]): static { $this->resize($width, $this->getHeight(), $constraints); return $this; } - public function height(int $height, array $constraints = [Constraint::PreserveAspectRatio]): self + public function height(int $height, array $constraints = [Constraint::PreserveAspectRatio]): static { $this->resize($this->getWidth(), $height, $constraints); return $this; } - public function border(int $width, BorderType $type, string $color = '000000'): self + public function border(int $width, BorderType $type, string $color = '000000'): static { if ($type === BorderType::Shrink) { $originalWidth = $this->getWidth(); @@ -507,14 +507,14 @@ public function border(int $width, BorderType $type, string $color = '000000'): } } - public function quality(int $quality): self + public function quality(int $quality): static { $this->image->setCompressionQuality(100 - $quality); return $this; } - public function format(string $format): ImageDriver + public function format(string $format): static { $this->image->setFormat($format); diff --git a/src/Image.php b/src/Image.php index ec1c6282..e1e300aa 100644 --- a/src/Image.php +++ b/src/Image.php @@ -30,7 +30,7 @@ public function __construct(protected ?string $pathToImage = null) $this->imageDriver = new ImagickDriver(); } - public static function load(string $pathToImage): ImageDriver + public static function load(string $pathToImage): static { if (! file_exists($pathToImage)) { throw CouldNotLoadImage::fileDoesNotExist($pathToImage); @@ -39,14 +39,14 @@ public static function load(string $pathToImage): ImageDriver return new static($pathToImage); } - public function loadFile(string $pathToImage): ImageDriver + public function loadFile(string $pathToImage): static { $this->imageDriver->loadFile($pathToImage); return $this; } - public static function useImageDriver(ImageDriverEnum|string $imageDriver): ImageDriver + public static function useImageDriver(ImageDriverEnum|string $imageDriver): static { if (is_string($imageDriver)) { $imageDriver = ImageDriverEnum::tryFrom($imageDriver) @@ -64,7 +64,7 @@ public static function useImageDriver(ImageDriverEnum|string $imageDriver): Imag return $image; } - public function new(int $width, int $height, ?string $backgroundColor = null): ImageDriver + public function new(int $width, int $height, ?string $backgroundColor = null): static { $this->imageDriver->new($width, $height, $backgroundColor); @@ -76,7 +76,7 @@ public function driverName(): string return $this->imageDriver->driverName(); } - public function save(string $path = ''): ImageDriver + public function save(string $path = ''): static { $this->imageDriver->save($path); @@ -93,7 +93,7 @@ public function getHeight(): int return $this->imageDriver->getHeight(); } - public function brightness(int $brightness): self + public function brightness(int $brightness): static { $this->ensureNumberBetween($brightness, -100, 100, 'brightness'); @@ -102,7 +102,7 @@ public function brightness(int $brightness): self return $this; } - public function gamma(float $gamma): ImageDriver + public function gamma(float $gamma): static { $this->ensureNumberBetween($gamma, 0.1, 9.99, 'gamma'); @@ -111,7 +111,7 @@ public function gamma(float $gamma): ImageDriver return $this; } - public function contrast(float $level): ImageDriver + public function contrast(float $level): static { $this->ensureNumberBetween($level, -100, 100, 'contrast'); @@ -120,7 +120,7 @@ public function contrast(float $level): ImageDriver return $this; } - public function blur(int $blur): ImageDriver + public function blur(int $blur): static { $this->ensureNumberBetween($blur, 0, 100, 'blur'); @@ -129,7 +129,7 @@ public function blur(int $blur): ImageDriver return $this; } - public function colorize(int $red, int $green, int $blue): ImageDriver + public function colorize(int $red, int $green, int $blue): static { $this->ensureNumberBetween($red, -100, 100, 'red'); $this->ensureNumberBetween($green, -100, 100, 'green'); @@ -140,21 +140,21 @@ public function colorize(int $red, int $green, int $blue): ImageDriver return $this; } - public function greyscale(): ImageDriver + public function greyscale(): static { $this->imageDriver->greyscale(); return $this; } - public function sepia(): ImageDriver + public function sepia(): static { $this->imageDriver->sepia(); return $this; } - public function sharpen(float $amount): ImageDriver + public function sharpen(float $amount): static { $this->ensureNumberBetween($amount, 0, 100, 'sharpen'); @@ -168,7 +168,7 @@ public function getSize(): Size return $this->imageDriver->getSize(); } - public function fit(Fit $fit, ?int $desiredWidth = null, ?int $desiredHeight = null): ImageDriver + public function fit(Fit $fit, ?int $desiredWidth = null, ?int $desiredHeight = null): static { $this->imageDriver->fit($fit, $desiredWidth, $desiredHeight); @@ -180,28 +180,28 @@ public function pickColor(int $x, int $y, ColorFormat $colorFormat): mixed return $this->imageDriver->pickColor($x, $y, $colorFormat); } - public function resizeCanvas(?int $width = null, ?int $height = null, ?AlignPosition $position = null, bool $relative = false, string $backgroundColor = '#000000'): ImageDriver + public function resizeCanvas(?int $width = null, ?int $height = null, ?AlignPosition $position = null, bool $relative = false, string $backgroundColor = '#000000'): static { $this->imageDriver->resizeCanvas($width, $height, $position, $relative, $backgroundColor); return $this; } - public function manualCrop(int $width, int $height, ?int $x = null, ?int $y = null): ImageDriver + public function manualCrop(int $width, int $height, ?int $x = null, ?int $y = null): static { $this->imageDriver->manualCrop($width, $height, $x, $y); return $this; } - public function crop(int $width, int $height, CropPosition $position = CropPosition::Center): ImageDriver + public function crop(int $width, int $height, CropPosition $position = CropPosition::Center): static { $this->imageDriver->crop($width, $height, $position); return $this; } - public function focalCrop(int $width, int $height, ?int $cropCenterX = null, ?int $cropCenterY = null): self + public function focalCrop(int $width, int $height, ?int $cropCenterX = null, ?int $cropCenterY = null): static { $this->imageDriver->focalCrop($width, $height, $cropCenterX, $cropCenterY); @@ -213,21 +213,21 @@ public function base64(string $imageFormat = 'jpeg', bool $prefixWithFormat = tr return $this->imageDriver->base64($imageFormat); } - public function background(string $color): ImageDriver + public function background(string $color): static { $this->imageDriver->background($color); return $this; } - public function overlay(ImageDriver $bottomImage, ImageDriver $topImage, int $x, int $y): ImageDriver + public function overlay(ImageDriver $bottomImage, ImageDriver $topImage, int $x, int $y): static { $this->imageDriver->overlay($bottomImage, $topImage, $x, $y); return $this; } - public function orientation(?Orientation $orientation = null): ImageDriver + public function orientation(?Orientation $orientation = null): static { $this->imageDriver->orientation($orientation); @@ -239,14 +239,14 @@ public function exif(): array return $this->imageDriver->exif(); } - public function flip(FlipDirection $flip): ImageDriver + public function flip(FlipDirection $flip): static { $this->imageDriver->flip($flip); return $this; } - public function pixelate(int $pixelate = 50): ImageDriver + public function pixelate(int $pixelate = 50): static { $this->ensureNumberBetween($pixelate, 0, 100, 'pixelate'); @@ -255,7 +255,7 @@ public function pixelate(int $pixelate = 50): ImageDriver return $this; } - public function insert(ImageDriver|string $otherImage, AlignPosition $position = AlignPosition::Center, int $x = 0, int $y = 0): ImageDriver + public function insert(ImageDriver|string $otherImage, AlignPosition $position = AlignPosition::Center, int $x = 0, int $y = 0): static { $this->imageDriver->insert($otherImage, $position, $x, $y); @@ -267,35 +267,35 @@ public function image(): mixed return $this->imageDriver->image(); } - public function resize(int $width, int $height, array $constraints = []): ImageDriver + public function resize(int $width, int $height, array $constraints = []): static { $this->imageDriver->resize($width, $height, $constraints); return $this; } - public function width(int $width, array $constraints = [Constraint::PreserveAspectRatio]): ImageDriver + public function width(int $width, array $constraints = [Constraint::PreserveAspectRatio]): static { $this->imageDriver->width($width, $constraints); return $this; } - public function height(int $height, array $constraints = [Constraint::PreserveAspectRatio]): ImageDriver + public function height(int $height, array $constraints = [Constraint::PreserveAspectRatio]): static { $this->imageDriver->height($height, $constraints); return $this; } - public function border(int $width, BorderType $type, string $color = '000000'): ImageDriver + public function border(int $width, BorderType $type, string $color = '000000'): static { $this->imageDriver->border($width, $type, $color); return $this; } - public function quality(int $quality): ImageDriver + public function quality(int $quality): static { $this->ensureNumberBetween($quality, 0, 100, 'quality'); @@ -304,14 +304,14 @@ public function quality(int $quality): ImageDriver return $this; } - public function format(string $format): ImageDriver + public function format(string $format): static { $this->imageDriver->format($format); return $this; } - public function optimize(?OptimizerChain $optimizerChain = null): ImageDriver + public function optimize(?OptimizerChain $optimizerChain = null): static { $this->imageDriver->optimize($optimizerChain);