diff --git a/src/mako/pixel/image/inspectors/ColorAt.php b/src/mako/pixel/image/inspectors/ColorAt.php new file mode 100644 index 000000000..67b64af26 --- /dev/null +++ b/src/mako/pixel/image/inspectors/ColorAt.php @@ -0,0 +1,30 @@ + + */ +abstract class ColorAt implements InspectorInterface +{ + use PixelValidationTrait; + + /** + * Constructor. + */ + final public function __construct( + protected Point $pixel + ) { + } +} diff --git a/src/mako/pixel/image/inspectors/ColorSpace.php b/src/mako/pixel/image/inspectors/ColorSpace.php new file mode 100644 index 000000000..4048eaa69 --- /dev/null +++ b/src/mako/pixel/image/inspectors/ColorSpace.php @@ -0,0 +1,20 @@ + + */ +abstract class ColorSpace implements InspectorInterface +{ + +} diff --git a/src/mako/pixel/image/inspectors/TopColors.php b/src/mako/pixel/image/inspectors/TopColors.php new file mode 100644 index 000000000..04e077c02 --- /dev/null +++ b/src/mako/pixel/image/inspectors/TopColors.php @@ -0,0 +1,30 @@ +> + */ +abstract class TopColors implements InspectorInterface +{ + /** + * Constructor. + */ + final public function __construct( + protected int $limit = 5, + protected bool $ignoreTransparent = true, + ) { + } +} diff --git a/src/mako/pixel/image/inspectors/gd/ColorAt.php b/src/mako/pixel/image/inspectors/gd/ColorAt.php index ac9159df8..06b01c68f 100644 --- a/src/mako/pixel/image/inspectors/gd/ColorAt.php +++ b/src/mako/pixel/image/inspectors/gd/ColorAt.php @@ -9,8 +9,7 @@ use GdImage; use mako\pixel\image\Color; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\inspectors\InspectorInterface; +use mako\pixel\image\inspectors\ColorAt as BaseColorAt; use mako\pixel\image\traits\GdTrait; use mako\pixel\image\traits\PixelValidationTrait; use Override; @@ -20,23 +19,13 @@ use function imagesy; /** - * Returns the color of the specified pixel. - * - * @implements InspectorInterface + * {@inheritDoc} */ -class ColorAt implements InspectorInterface +class ColorAt extends BaseColorAt { use GdTrait; use PixelValidationTrait; - /** - * Constructor. - */ - public function __construct( - protected Point $pixel - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/inspectors/gd/TopColors.php b/src/mako/pixel/image/inspectors/gd/TopColors.php index e0a69e393..80eedcda1 100644 --- a/src/mako/pixel/image/inspectors/gd/TopColors.php +++ b/src/mako/pixel/image/inspectors/gd/TopColors.php @@ -9,7 +9,7 @@ use GdImage; use mako\pixel\image\Color; -use mako\pixel\image\inspectors\InspectorInterface; +use mako\pixel\image\inspectors\TopColors as BaseTopColors; use mako\pixel\image\traits\GdTrait; use Override; @@ -24,14 +24,9 @@ use function usort; /** - * Extracts the dominant colors from an image. - * - * Similar colors are grouped together to avoid returning multiple - * variations of the same color. - * - * @implements InspectorInterface> + * {@inheritDoc} */ -class TopColors implements InspectorInterface +class TopColors extends BaseTopColors { use GdTrait; @@ -41,15 +36,6 @@ class TopColors implements InspectorInterface */ protected const int MAX_SAMPLE_STEP = 8; - /** - * Constructor. - */ - public function __construct( - protected int $limit = 5, - protected bool $ignoreTransparent = true - ) { - } - /** * Calculates the sampling step size based on image dimensions. * diff --git a/src/mako/pixel/image/inspectors/imagemagick/ColorAt.php b/src/mako/pixel/image/inspectors/imagemagick/ColorAt.php index 6a9299dff..fbd34f376 100644 --- a/src/mako/pixel/image/inspectors/imagemagick/ColorAt.php +++ b/src/mako/pixel/image/inspectors/imagemagick/ColorAt.php @@ -9,28 +9,17 @@ use Imagick; use mako\pixel\image\Color; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\inspectors\InspectorInterface; +use mako\pixel\image\inspectors\ColorAt as BaseColorAt; use mako\pixel\image\traits\PixelValidationTrait; use Override; /** - * Returns the color of the specified pixel. - * - * @implements InspectorInterface + * @inheritDoc} */ -class ColorAt implements InspectorInterface +class ColorAt extends BaseColorAt { use PixelValidationTrait; - /** - * Constructor. - */ - public function __construct( - protected Point $pixel - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/inspectors/imagemagick/ColorSpace.php b/src/mako/pixel/image/inspectors/imagemagick/ColorSpace.php index 4a61bbb72..27a1e2bf0 100644 --- a/src/mako/pixel/image/inspectors/imagemagick/ColorSpace.php +++ b/src/mako/pixel/image/inspectors/imagemagick/ColorSpace.php @@ -9,7 +9,7 @@ use Imagick; use mako\pixel\image\ColorSpace as ColorSpaceEnum; -use mako\pixel\image\inspectors\InspectorInterface; +use mako\pixel\image\inspectors\ColorSpace as BaseColorSpace; use Override; use ReflectionClass; @@ -18,11 +18,9 @@ use function strtolower; /** - * Returns the color space of the image. - * - * @implements InspectorInterface + * {@inheritDoc} */ -class ColorSpace implements InspectorInterface +class ColorSpace extends BaseColorSpace { /** * Returns a map of the available color spaces. diff --git a/src/mako/pixel/image/inspectors/imagemagick/TopColors.php b/src/mako/pixel/image/inspectors/imagemagick/TopColors.php index b53c4119b..9c5fa1c2d 100644 --- a/src/mako/pixel/image/inspectors/imagemagick/TopColors.php +++ b/src/mako/pixel/image/inspectors/imagemagick/TopColors.php @@ -9,31 +9,17 @@ use Imagick; use mako\pixel\image\Color; -use mako\pixel\image\inspectors\InspectorInterface; +use mako\pixel\image\inspectors\TopColors as BaseTopColors; use Override; use function array_slice; use function usort; /** - * Extracts the dominant colors from an image. - * - * Similar colors are grouped together to avoid returning multiple - * variations of the same color. - * - * @implements InspectorInterface> + * {@inheritDoc} */ -class TopColors implements InspectorInterface +class TopColors extends BaseTopColors { - /** - * Constructor. - */ - public function __construct( - protected int $limit = 5, - protected bool $ignoreTransparent = true, - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/Bezier.php b/src/mako/pixel/image/operations/Bezier.php new file mode 100644 index 000000000..cd34b106a --- /dev/null +++ b/src/mako/pixel/image/operations/Bezier.php @@ -0,0 +1,39 @@ +strokeWidth < 1) { + throw new InvalidArgumentException('Stroke width must be greater than 0.'); + } + } +} diff --git a/src/mako/pixel/image/operations/Bitonal.php b/src/mako/pixel/image/operations/Bitonal.php new file mode 100644 index 000000000..b55c3403d --- /dev/null +++ b/src/mako/pixel/image/operations/Bitonal.php @@ -0,0 +1,16 @@ +width = max(0, $this->width); + } +} diff --git a/src/mako/pixel/image/operations/Brightness.php b/src/mako/pixel/image/operations/Brightness.php new file mode 100644 index 000000000..fcb59fd1a --- /dev/null +++ b/src/mako/pixel/image/operations/Brightness.php @@ -0,0 +1,22 @@ +fill === null && $this->stroke === null) { + throw new InvalidArgumentException('A circle requires a fill, a stroke, or both.'); + } + + if ($this->stroke !== null && $this->strokeWidth < 1) { + throw new InvalidArgumentException('Stroke width must be greater than 0.'); + } + } +} diff --git a/src/mako/pixel/image/operations/ColorSpace.php b/src/mako/pixel/image/operations/ColorSpace.php new file mode 100644 index 000000000..4ed038bae --- /dev/null +++ b/src/mako/pixel/image/operations/ColorSpace.php @@ -0,0 +1,24 @@ +image = $image; + } +} diff --git a/src/mako/pixel/image/operations/Contrast.php b/src/mako/pixel/image/operations/Contrast.php new file mode 100644 index 000000000..57461e20e --- /dev/null +++ b/src/mako/pixel/image/operations/Contrast.php @@ -0,0 +1,22 @@ +fill === null && $this->stroke === null) { + throw new InvalidArgumentException('An ellipse requires a fill, a stroke, or both.'); + } + + if ($this->stroke !== null && $this->strokeWidth < 1) { + throw new InvalidArgumentException('Stroke width must be greater than 0.'); + } + } +} diff --git a/src/mako/pixel/image/operations/Flip.php b/src/mako/pixel/image/operations/Flip.php index 16cc9907a..ea623ed0f 100644 --- a/src/mako/pixel/image/operations/Flip.php +++ b/src/mako/pixel/image/operations/Flip.php @@ -8,17 +8,15 @@ namespace mako\pixel\image\operations; /** - * Flip. + * Flips the image. */ -enum Flip +abstract class Flip implements OperationInterface { /** - * Flip horizontally. + * Constructor. */ - case Horizontal; - - /** - * Flip vertically. - */ - case Vertical; + final public function __construct( + protected FlipDirection $direction = FlipDirection::Horizontal + ) { + } } diff --git a/src/mako/pixel/image/operations/FlipDirection.php b/src/mako/pixel/image/operations/FlipDirection.php new file mode 100644 index 000000000..a7d30b335 --- /dev/null +++ b/src/mako/pixel/image/operations/FlipDirection.php @@ -0,0 +1,24 @@ +fill === null && $this->stroke === null) { + throw new InvalidArgumentException('A polygon requires a fill, a stroke, or both.'); + } + + if ($this->stroke !== null && $this->strokeWidth < 1) { + throw new InvalidArgumentException('Stroke width must be greater than 0.'); + } + } +} diff --git a/src/mako/pixel/image/operations/Polyline.php b/src/mako/pixel/image/operations/Polyline.php new file mode 100644 index 000000000..cf0509c18 --- /dev/null +++ b/src/mako/pixel/image/operations/Polyline.php @@ -0,0 +1,39 @@ +strokeWidth < 1) { + throw new InvalidArgumentException('Stroke width must be greater than 0.'); + } + } +} diff --git a/src/mako/pixel/image/operations/Rectangle.php b/src/mako/pixel/image/operations/Rectangle.php new file mode 100644 index 000000000..e25cd6627 --- /dev/null +++ b/src/mako/pixel/image/operations/Rectangle.php @@ -0,0 +1,38 @@ +fill === null && $this->stroke === null) { + throw new InvalidArgumentException('A rectangle requires a fill, a stroke, or both.'); + } + + if ($this->stroke !== null && $this->strokeWidth < 1) { + throw new InvalidArgumentException('Stroke width must be greater than 0.'); + } + } +} diff --git a/src/mako/pixel/image/operations/ReplaceColor.php b/src/mako/pixel/image/operations/ReplaceColor.php new file mode 100644 index 000000000..7dbf7f37e --- /dev/null +++ b/src/mako/pixel/image/operations/ReplaceColor.php @@ -0,0 +1,27 @@ +fill === null && $this->stroke === null) { + throw new InvalidArgumentException('A rounded rectangle requires a fill, a stroke, or both.'); + } + + if ($this->stroke !== null && $this->strokeWidth < 1) { + throw new InvalidArgumentException('Stroke width must be greater than 0.'); + } + + // Clamp the radius so that it never exceeds half the width or height, + // preventing corner arcs from overlapping and producing a malformed polygon. + + $this->radius = min( + $this->radius, + (int) floor($this->dimensions->width / 2), + (int) floor($this->dimensions->height / 2), + ); + } +} diff --git a/src/mako/pixel/image/operations/Saturation.php b/src/mako/pixel/image/operations/Saturation.php new file mode 100644 index 000000000..384c5df3a --- /dev/null +++ b/src/mako/pixel/image/operations/Saturation.php @@ -0,0 +1,22 @@ +percent = $value; + } + }, + ) { + } +} diff --git a/src/mako/pixel/image/operations/Sepia.php b/src/mako/pixel/image/operations/Sepia.php new file mode 100644 index 000000000..315e3125e --- /dev/null +++ b/src/mako/pixel/image/operations/Sepia.php @@ -0,0 +1,16 @@ +stroke !== null && $this->strokeWidth < 1) { + throw new InvalidArgumentException('Stroke width must be greater than 0.'); + } + } +} diff --git a/src/mako/pixel/image/operations/Watermark.php b/src/mako/pixel/image/operations/Watermark.php new file mode 100644 index 000000000..1ca5a72d5 --- /dev/null +++ b/src/mako/pixel/image/operations/Watermark.php @@ -0,0 +1,39 @@ +image = $image; + } +} diff --git a/src/mako/pixel/image/operations/gd/Bezier.php b/src/mako/pixel/image/operations/gd/Bezier.php index 4c3f13752..afa65e3f1 100644 --- a/src/mako/pixel/image/operations/gd/Bezier.php +++ b/src/mako/pixel/image/operations/gd/Bezier.php @@ -8,11 +8,7 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use InvalidArgumentException; -use mako\pixel\image\Color; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\geometry\Points; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Bezier as BaseBezier; use mako\pixel\image\traits\GdTrait; use Override; @@ -22,9 +18,9 @@ use function imagesetthickness; /** - * Draws a Bézier curve on the image. + * {@inheritDoc} */ -class Bezier implements OperationInterface +class Bezier extends BaseBezier { use GdTrait; @@ -33,24 +29,6 @@ class Bezier implements OperationInterface */ protected const int SEGMENTS = 100; - /** - * Constructor. - */ - public function __construct( - protected Points $points, - protected Color $stroke, - protected int $strokeWidth = 1, - protected Point $position = new Point(0, 0) - ) { - if (count($points) < 2) { - throw new InvalidArgumentException('A Bézier curve requires at least 2 points.'); - } - - if ($this->strokeWidth < 1) { - throw new InvalidArgumentException('Stroke width must be greater than 0.'); - } - } - /** * Calculates a point on the Bézier curve at position t using De Casteljau's algorithm. */ diff --git a/src/mako/pixel/image/operations/gd/Bitonal.php b/src/mako/pixel/image/operations/gd/Bitonal.php index b4de89f09..a3ba52ed5 100644 --- a/src/mako/pixel/image/operations/gd/Bitonal.php +++ b/src/mako/pixel/image/operations/gd/Bitonal.php @@ -8,15 +8,15 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Bitonal as BaseBitonal; use Override; use function imagefilter; /** - * Turns the image into bitonal. + * {@inheritDoc} */ -class Bitonal implements OperationInterface +class Bitonal extends BaseBitonal { /** * {@inheritDoc} diff --git a/src/mako/pixel/image/operations/gd/Border.php b/src/mako/pixel/image/operations/gd/Border.php index dbe2f869d..f7e68849d 100644 --- a/src/mako/pixel/image/operations/gd/Border.php +++ b/src/mako/pixel/image/operations/gd/Border.php @@ -8,33 +8,21 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use mako\pixel\image\Color; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Border as BaseBorder; use mako\pixel\image\traits\GdTrait; use Override; use function imagerectangle; use function imagesx; use function imagesy; -use function max; /** - * Adds a border to the image. + * {@inheritDoc} */ -class Border implements OperationInterface +class Border extends BaseBorder { use GdTrait; - /** - * Constructor. - */ - public function __construct( - protected Color $color = new Color(0, 0, 0), - protected int $width = 4 - ) { - $this->width = max(0, $this->width); - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Brightness.php b/src/mako/pixel/image/operations/gd/Brightness.php index 4bdac282e..72f2ce83d 100644 --- a/src/mako/pixel/image/operations/gd/Brightness.php +++ b/src/mako/pixel/image/operations/gd/Brightness.php @@ -8,27 +8,19 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Brightness as BaseBrightness; use mako\pixel\image\operations\traits\NormalizeTrait; use Override; use function imagefilter; /** - * Adjusts the image brightness. + * {@inheritDoc} */ -class Brightness implements OperationInterface +class Brightness extends BaseBrightness { use NormalizeTrait; - /** - * Constructor. - */ - public function __construct( - protected int $level = 0 - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Circle.php b/src/mako/pixel/image/operations/gd/Circle.php index 65e4a1f42..f1d52786f 100644 --- a/src/mako/pixel/image/operations/gd/Circle.php +++ b/src/mako/pixel/image/operations/gd/Circle.php @@ -8,10 +8,7 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use InvalidArgumentException; -use mako\pixel\image\Color; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Circle as BaseCircle; use mako\pixel\image\traits\GdTrait; use Override; @@ -21,31 +18,12 @@ use function imagesetthickness; /** - * Draws a circle on the image. + * {@inheritDoc} */ -class Circle implements OperationInterface +class Circle extends BaseCircle { use GdTrait; - /** - * Constructor. - */ - public function __construct( - protected int $radius, - protected ?Color $fill = null, - protected ?Color $stroke = null, - protected int $strokeWidth = 1, - protected Point $center = new Point(0, 0) - ) { - if ($this->fill === null && $this->stroke === null) { - throw new InvalidArgumentException('A circle requires a fill, a stroke, or both.'); - } - - if ($this->stroke !== null && $this->strokeWidth < 1) { - throw new InvalidArgumentException('Stroke width must be greater than 0.'); - } - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Colorize.php b/src/mako/pixel/image/operations/gd/Colorize.php index 4fd7c3f0c..94d60c116 100644 --- a/src/mako/pixel/image/operations/gd/Colorize.php +++ b/src/mako/pixel/image/operations/gd/Colorize.php @@ -8,8 +8,7 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use mako\pixel\image\Color; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Colorize as BaseColorize; use Override; use function imagealphablending; @@ -23,18 +22,10 @@ use function min; /** - * Colorizes the image. + * {@inheritDoc} */ -class Colorize implements OperationInterface +class Colorize extends BaseColorize { - /** - * Constructor. - */ - public function __construct( - protected Color $color - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Composite.php b/src/mako/pixel/image/operations/gd/Composite.php index aa3c2c25a..662898d08 100644 --- a/src/mako/pixel/image/operations/gd/Composite.php +++ b/src/mako/pixel/image/operations/gd/Composite.php @@ -9,8 +9,7 @@ use GdImage; use mako\pixel\image\Gd; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Composite as BaseComposite; use Override; use function imagecopy; @@ -18,16 +17,12 @@ use function imagesy; /** - * Composites an image onto the image at the specified position. + * {@inheritDoc} + * + * @extends BaseComposite */ -class Composite implements OperationInterface +class Composite extends BaseComposite { - public function __construct( - protected Gd $image, - protected Point $position = new Point(0, 0) - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Contrast.php b/src/mako/pixel/image/operations/gd/Contrast.php index 51ccdd286..b4762e6a0 100644 --- a/src/mako/pixel/image/operations/gd/Contrast.php +++ b/src/mako/pixel/image/operations/gd/Contrast.php @@ -8,27 +8,19 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Contrast as BaseContrast; use mako\pixel\image\operations\traits\NormalizeTrait; use Override; use function imagefilter; /** - * Adjusts the image contrast. + * {@inheritDoc} */ -class Contrast implements OperationInterface +class Contrast extends BaseContrast { use NormalizeTrait; - /** - * Constructor. - */ - public function __construct( - protected int $level = 0 - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Crop.php b/src/mako/pixel/image/operations/gd/Crop.php index 00a0df14f..0f5d2d235 100644 --- a/src/mako/pixel/image/operations/gd/Crop.php +++ b/src/mako/pixel/image/operations/gd/Crop.php @@ -9,9 +9,7 @@ use GdImage; use mako\pixel\image\exceptions\ImageException; -use mako\pixel\image\geometry\Dimensions; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Crop as BaseCrop; use Override; use function imagecolorallocatealpha; @@ -23,19 +21,10 @@ use function imagesy; /** - * Crops the image. + * {@inheritDoc} */ -class Crop implements OperationInterface +class Crop extends BaseCrop { - /** - * Constructor. - */ - public function __construct( - protected Dimensions $dimensions, - protected Point $position - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Ellipse.php b/src/mako/pixel/image/operations/gd/Ellipse.php index ff8605037..88ad517ea 100644 --- a/src/mako/pixel/image/operations/gd/Ellipse.php +++ b/src/mako/pixel/image/operations/gd/Ellipse.php @@ -8,11 +8,7 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use InvalidArgumentException; -use mako\pixel\image\Color; -use mako\pixel\image\geometry\Dimensions; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Ellipse as BaseEllipse; use mako\pixel\image\traits\GdTrait; use Override; @@ -22,31 +18,12 @@ use function imagesetthickness; /** - * Draws an ellipse on the image. + * {@inheritDoc} */ -class Ellipse implements OperationInterface +class Ellipse extends BaseEllipse { use GdTrait; - /** - * Constructor. - */ - public function __construct( - protected Dimensions $dimensions, - protected ?Color $fill = null, - protected ?Color $stroke = null, - protected int $strokeWidth = 1, - protected Point $center = new Point(0, 0) - ) { - if ($this->fill === null && $this->stroke === null) { - throw new InvalidArgumentException('An ellipse requires a fill, a stroke, or both.'); - } - - if ($this->stroke !== null && $this->strokeWidth < 1) { - throw new InvalidArgumentException('Stroke width must be greater than 0.'); - } - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Flip.php b/src/mako/pixel/image/operations/gd/Flip.php index 6065a728d..51003b9d5 100644 --- a/src/mako/pixel/image/operations/gd/Flip.php +++ b/src/mako/pixel/image/operations/gd/Flip.php @@ -9,8 +9,8 @@ use GdImage; use mako\pixel\image\exceptions\ImageException; -use mako\pixel\image\operations\Flip as FlipDirection; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Flip as BaseFlip; +use mako\pixel\image\operations\FlipDirection; use Override; use function imagecolorallocatealpha; @@ -22,18 +22,10 @@ use function imagesy; /** - * Flips the image. + * {@inheritDoc} */ -class Flip implements OperationInterface +class Flip extends BaseFlip { - /** - * Constructor. - */ - public function __construct( - protected FlipDirection $direction = FlipDirection::Horizontal - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Gamma.php b/src/mako/pixel/image/operations/gd/Gamma.php index 4c52e1ba4..adcb020b6 100644 --- a/src/mako/pixel/image/operations/gd/Gamma.php +++ b/src/mako/pixel/image/operations/gd/Gamma.php @@ -8,28 +8,16 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use InvalidArgumentException; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Gamma as BaseGamma; use Override; use function imagegammacorrect; /** - * Adjusts the gamma level of the image. + * {@inheritDoc} */ -class Gamma implements OperationInterface +class Gamma extends BaseGamma { - /** - * Constructor. - */ - public function __construct( - protected float $gamma - ) { - if ($gamma <= 0) { - throw new InvalidArgumentException('Gamma must be greater than 0.'); - } - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Greyscale.php b/src/mako/pixel/image/operations/gd/Greyscale.php index 8bc7749f5..01ad4d5a4 100644 --- a/src/mako/pixel/image/operations/gd/Greyscale.php +++ b/src/mako/pixel/image/operations/gd/Greyscale.php @@ -8,15 +8,15 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Greyscale as BaseGreyscale; use Override; use function imagefilter; /** - * Turns the image into greyscale. + * {@inheritDoc} */ -class Greyscale implements OperationInterface +class Greyscale extends BaseGreyscale { /** * {@inheritDoc} diff --git a/src/mako/pixel/image/operations/gd/Invert.php b/src/mako/pixel/image/operations/gd/Invert.php index 6ab3bf5f0..504af4b3c 100644 --- a/src/mako/pixel/image/operations/gd/Invert.php +++ b/src/mako/pixel/image/operations/gd/Invert.php @@ -8,15 +8,15 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Invert as BaseInvert; use Override; use function imagefilter; /** - * Inverts the colors of the image. + * {@inheritDoc} */ -class Invert implements OperationInterface +class Invert extends BaseInvert { /** * {@inheritDoc} diff --git a/src/mako/pixel/image/operations/gd/Opacity.php b/src/mako/pixel/image/operations/gd/Opacity.php index 3d16a7348..251205b66 100644 --- a/src/mako/pixel/image/operations/gd/Opacity.php +++ b/src/mako/pixel/image/operations/gd/Opacity.php @@ -8,7 +8,7 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Opacity as BaseOpacity; use mako\pixel\image\operations\traits\NormalizeTrait; use mako\pixel\image\traits\GdTrait; use Override; @@ -22,18 +22,13 @@ use function round; /** - * Adjusts the opacity of the image. + * {@inheritDoc} */ -class Opacity implements OperationInterface +class Opacity extends BaseOpacity { use GdTrait; use NormalizeTrait; - public function __construct( - protected int $opacity - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Pixel.php b/src/mako/pixel/image/operations/gd/Pixel.php index 63f764a86..655985ab1 100644 --- a/src/mako/pixel/image/operations/gd/Pixel.php +++ b/src/mako/pixel/image/operations/gd/Pixel.php @@ -8,9 +8,7 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use mako\pixel\image\Color; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Pixel as BasePixel; use mako\pixel\image\traits\GdTrait; use mako\pixel\image\traits\PixelValidationTrait; use Override; @@ -20,22 +18,13 @@ use function imagesy; /** - * Draws a pixel on the image at the specified coordinates. + * {@inheritDoc} */ -class Pixel implements OperationInterface +class Pixel extends BasePixel { use GdTrait; use PixelValidationTrait; - /** - * Constructor. - */ - public function __construct( - protected Point $pixel, - protected Color $color - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Pixelate.php b/src/mako/pixel/image/operations/gd/Pixelate.php index 69f85f9d4..8259fd75d 100644 --- a/src/mako/pixel/image/operations/gd/Pixelate.php +++ b/src/mako/pixel/image/operations/gd/Pixelate.php @@ -8,24 +8,16 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Pixelate as BasePixelate; use Override; use function imagefilter; /** - * Pixelates the image. + * {@inheritDoc} */ -class Pixelate implements OperationInterface +class Pixelate extends BasePixelate { - /** - * Constructor. - */ - public function __construct( - protected int $pixelSize = 10 - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Polygon.php b/src/mako/pixel/image/operations/gd/Polygon.php index 0ace99231..5956d943a 100644 --- a/src/mako/pixel/image/operations/gd/Polygon.php +++ b/src/mako/pixel/image/operations/gd/Polygon.php @@ -8,50 +8,22 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use InvalidArgumentException; -use mako\pixel\image\Color; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\geometry\Points; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Polygon as BasePolygon; use mako\pixel\image\traits\GdTrait; use Override; -use function count; use function imagealphablending; use function imagefilledpolygon; use function imagepolygon; use function imagesetthickness; /** - * Draws a polygon on the image. + * {@inheritDoc} */ -class Polygon implements OperationInterface +class Polygon extends BasePolygon { use GdTrait; - /** - * Constructor. - */ - public function __construct( - protected Points $points, - protected ?Color $fill = null, - protected ?Color $stroke = null, - protected int $strokeWidth = 1, - protected Point $position = new Point(0, 0) - ) { - if (count($points) < 3) { - throw new InvalidArgumentException('A polygon requires at least 3 points.'); - } - - if ($this->fill === null && $this->stroke === null) { - throw new InvalidArgumentException('A polygon requires a fill, a stroke, or both.'); - } - - if ($this->stroke !== null && $this->strokeWidth < 1) { - throw new InvalidArgumentException('Stroke width must be greater than 0.'); - } - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Polyline.php b/src/mako/pixel/image/operations/gd/Polyline.php index ecce2bed3..0df33ec6d 100644 --- a/src/mako/pixel/image/operations/gd/Polyline.php +++ b/src/mako/pixel/image/operations/gd/Polyline.php @@ -8,44 +8,21 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use InvalidArgumentException; -use mako\pixel\image\Color; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\geometry\Points; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Polyline as BasePolyline; use mako\pixel\image\traits\GdTrait; use Override; -use function count; use function imagealphablending; use function imageline; use function imagesetthickness; /** - * Draws a polyline on the image. + * {@inheritDoc} */ -class Polyline implements OperationInterface +class Polyline extends BasePolyline { use GdTrait; - /** - * Constructor. - */ - public function __construct( - protected Points $points, - protected Color $stroke, - protected int $strokeWidth = 1, - protected Point $position = new Point(0, 0) - ) { - if (count($points) < 2) { - throw new InvalidArgumentException('A polyline requires at least 2 points.'); - } - - if ($this->strokeWidth < 1) { - throw new InvalidArgumentException('Stroke width must be greater than 0.'); - } - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Rectangle.php b/src/mako/pixel/image/operations/gd/Rectangle.php index 08f1b187e..14d8f4a3e 100644 --- a/src/mako/pixel/image/operations/gd/Rectangle.php +++ b/src/mako/pixel/image/operations/gd/Rectangle.php @@ -8,11 +8,7 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use InvalidArgumentException; -use mako\pixel\image\Color; -use mako\pixel\image\geometry\Dimensions; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Rectangle as BaseRectangle; use mako\pixel\image\traits\GdTrait; use Override; @@ -22,31 +18,12 @@ use function imagesetthickness; /** - * Draws a rectangle on the image. + * {@inheritDoc} */ -class Rectangle implements OperationInterface +class Rectangle extends BaseRectangle { use GdTrait; - /** - * Constructor. - */ - public function __construct( - protected Dimensions $dimensions, - protected ?Color $fill = null, - protected ?Color $stroke = null, - protected int $strokeWidth = 1, - protected Point $position = new Point(0, 0) - ) { - if ($this->fill === null && $this->stroke === null) { - throw new InvalidArgumentException('A rectangle requires a fill, a stroke, or both.'); - } - - if ($this->stroke !== null && $this->strokeWidth < 1) { - throw new InvalidArgumentException('Stroke width must be greater than 0.'); - } - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/ReplaceColor.php b/src/mako/pixel/image/operations/gd/ReplaceColor.php index 77d0c6bdb..8ab37b30d 100644 --- a/src/mako/pixel/image/operations/gd/ReplaceColor.php +++ b/src/mako/pixel/image/operations/gd/ReplaceColor.php @@ -8,8 +8,7 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use mako\pixel\image\Color; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\ReplaceColor as BaseReplaceColor; use mako\pixel\image\traits\GdTrait; use Override; @@ -24,23 +23,12 @@ use function min; /** - * Replaces pixels matching a specified color with another color. + * {@inheritDoc} */ -class ReplaceColor implements OperationInterface +class ReplaceColor extends BaseReplaceColor { use GdTrait; - /** - * Constructor. - */ - public function __construct( - protected Color $from, - protected Color $to, - protected int $tolerance = 0, - protected bool $invertMatch = false - ) { - } - /** * Converts tolerance percentage (0-100) to 8-bit channel range (0-255). */ diff --git a/src/mako/pixel/image/operations/gd/Resize.php b/src/mako/pixel/image/operations/gd/Resize.php index ee2e4b8c4..c1bc41f13 100644 --- a/src/mako/pixel/image/operations/gd/Resize.php +++ b/src/mako/pixel/image/operations/gd/Resize.php @@ -9,9 +9,7 @@ use GdImage; use mako\pixel\image\exceptions\ImageException; -use mako\pixel\image\geometry\Dimensions; -use mako\pixel\image\operations\AspectRatio; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Resize as BaseResize; use mako\pixel\image\operations\traits\ResizeTrait; use Override; @@ -24,21 +22,12 @@ use function imagesy; /** - * Resizes the image. + * {@inheritDoc} */ -class Resize implements OperationInterface +class Resize extends BaseResize { use ResizeTrait; - /** - * Constructor. - */ - public function __construct( - protected Dimensions $dimensions, - protected AspectRatio $aspectRatio = AspectRatio::Auto - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Rotate.php b/src/mako/pixel/image/operations/gd/Rotate.php index 4b65bd0be..495b20545 100644 --- a/src/mako/pixel/image/operations/gd/Rotate.php +++ b/src/mako/pixel/image/operations/gd/Rotate.php @@ -9,7 +9,7 @@ use GdImage; use mako\pixel\image\exceptions\ImageException; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Rotate as BaseRotate; use Override; use function imagecolorallocatealpha; @@ -17,18 +17,10 @@ use function imagerotate; /** - * Rotates the image. + * {@inheritDoc} */ -class Rotate implements OperationInterface +class Rotate extends BaseRotate { - /** - * Constructor. - */ - public function __construct( - protected int $degrees = 0 - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/RoundedRectangle.php b/src/mako/pixel/image/operations/gd/RoundedRectangle.php index cbc66f70b..83b1dfbfb 100644 --- a/src/mako/pixel/image/operations/gd/RoundedRectangle.php +++ b/src/mako/pixel/image/operations/gd/RoundedRectangle.php @@ -8,29 +8,23 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use InvalidArgumentException; -use mako\pixel\image\Color; -use mako\pixel\image\geometry\Dimensions; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\RoundedRectangle as BaseRoundedRectangle; use mako\pixel\image\traits\GdTrait; use Override; use function cos; use function deg2rad; -use function floor; use function imagealphablending; use function imagearc; use function imagefilledpolygon; use function imageline; use function imagesetthickness; -use function min; use function sin; /** - * Draws a rounded rectangle on the image. + * {@inheritDoc} */ -class RoundedRectangle implements OperationInterface +class RoundedRectangle extends BaseRoundedRectangle { use GdTrait; @@ -39,35 +33,6 @@ class RoundedRectangle implements OperationInterface */ protected const int CORNER_SEGMENTS = 12; - /** - * Constructor. - */ - public function __construct( - protected Dimensions $dimensions, - protected int $radius, - protected ?Color $fill = null, - protected ?Color $stroke = null, - protected int $strokeWidth = 1, - protected Point $position = new Point(0, 0) - ) { - if ($this->fill === null && $this->stroke === null) { - throw new InvalidArgumentException('A rounded rectangle requires a fill, a stroke, or both.'); - } - - if ($this->stroke !== null && $this->strokeWidth < 1) { - throw new InvalidArgumentException('Stroke width must be greater than 0.'); - } - - // Clamp the radius so that it never exceeds half the width or height, - // preventing corner arcs from overlapping and producing a malformed polygon. - - $this->radius = min( - $this->radius, - (int) floor($this->dimensions->width / 2), - (int) floor($this->dimensions->height / 2), - ); - } - /** * Builds a point list approximating the rounded rectangle outline. */ diff --git a/src/mako/pixel/image/operations/gd/Saturation.php b/src/mako/pixel/image/operations/gd/Saturation.php index 0a1aa412c..5427e1ff9 100644 --- a/src/mako/pixel/image/operations/gd/Saturation.php +++ b/src/mako/pixel/image/operations/gd/Saturation.php @@ -8,7 +8,7 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Saturation as BaseSaturation; use mako\pixel\image\operations\traits\NormalizeTrait; use Override; @@ -23,20 +23,12 @@ use function min; /** - * Adjusts the color saturation. + * {@inheritDoc} */ -class Saturation implements OperationInterface +class Saturation extends BaseSaturation { use NormalizeTrait; - /** - * Constructor. - */ - public function __construct( - protected int $level = 0 - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Scale.php b/src/mako/pixel/image/operations/gd/Scale.php index 0d1b903da..1b456b640 100644 --- a/src/mako/pixel/image/operations/gd/Scale.php +++ b/src/mako/pixel/image/operations/gd/Scale.php @@ -8,9 +8,8 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use InvalidArgumentException; use mako\pixel\image\exceptions\ImageException; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Scale as BaseScale; use Override; use function imagecolorallocatealpha; @@ -23,25 +22,10 @@ use function round; /** - * Scales the image. + * {@inheritDoc} */ -class Scale implements OperationInterface +class Scale extends BaseScale { - /** - * Constructor. - */ - public function __construct( - protected int $percent { - set(int $value) { - if ($value <= 0) { - throw new InvalidArgumentException('Scale percentage must be greater than zero.'); - } - $this->percent = $value; - } - }, - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Sepia.php b/src/mako/pixel/image/operations/gd/Sepia.php index 17ec9ad73..942f4d321 100644 --- a/src/mako/pixel/image/operations/gd/Sepia.php +++ b/src/mako/pixel/image/operations/gd/Sepia.php @@ -8,7 +8,7 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Sepia as BaseSepia; use Override; use function imagealphablending; @@ -21,9 +21,9 @@ use function min; /** - * Turns the image into sepia. + * {@inheritDoc} */ -class Sepia implements OperationInterface +class Sepia extends BaseSepia { /** * {@inheritDoc} diff --git a/src/mako/pixel/image/operations/gd/Sharpen.php b/src/mako/pixel/image/operations/gd/Sharpen.php index e7ab4036b..3888bb431 100644 --- a/src/mako/pixel/image/operations/gd/Sharpen.php +++ b/src/mako/pixel/image/operations/gd/Sharpen.php @@ -8,7 +8,7 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Sharpen as BaseSharpen; use Override; use function array_map; @@ -16,9 +16,9 @@ use function imageconvolution; /** - * Sharpens the image. + * {@inheritDoc} */ -class Sharpen implements OperationInterface +class Sharpen extends BaseSharpen { /** * {@inheritDoc} diff --git a/src/mako/pixel/image/operations/gd/Temperature.php b/src/mako/pixel/image/operations/gd/Temperature.php index 52b8298e9..3d747c25e 100644 --- a/src/mako/pixel/image/operations/gd/Temperature.php +++ b/src/mako/pixel/image/operations/gd/Temperature.php @@ -8,7 +8,7 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Temperature as BaseTemperature; use mako\pixel\image\operations\traits\NormalizeTrait; use Override; @@ -22,20 +22,12 @@ use function min; /** - * Adjusts the image color temperature. + * {@inheritDoc} */ -class Temperature implements OperationInterface +class Temperature extends BaseTemperature { use NormalizeTrait; - /** - * Constructor. - */ - public function __construct( - protected int $level = 0 - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Text.php b/src/mako/pixel/image/operations/gd/Text.php index f18086ddf..b9d9a7fb3 100644 --- a/src/mako/pixel/image/operations/gd/Text.php +++ b/src/mako/pixel/image/operations/gd/Text.php @@ -8,31 +8,19 @@ namespace mako\pixel\image\operations\gd; use GdImage; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\operations\Font; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Text as BaseText; use mako\pixel\image\traits\GdTrait; use Override; use function imagettftext; /** - * Draws text on the image. + * {@inheritDoc} */ -class Text implements OperationInterface +class Text extends BaseText { use GdTrait; - /** - * Constructor. - */ - public function __construct( - protected string $text, - protected Font $font, - protected Point $position, - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/gd/Watermark.php b/src/mako/pixel/image/operations/gd/Watermark.php index 9e663b819..d5fc5ffad 100644 --- a/src/mako/pixel/image/operations/gd/Watermark.php +++ b/src/mako/pixel/image/operations/gd/Watermark.php @@ -10,32 +10,19 @@ use GdImage; use mako\pixel\image\Gd; use mako\pixel\image\geometry\Dimensions; -use mako\pixel\image\operations\OperationInterface; -use mako\pixel\image\operations\WatermarkPosition; +use mako\pixel\image\operations\Watermark as BaseWatermark; use Override; use function imagesx; use function imagesy; /** - * Adds a watermark to the image. + * {@inheritDoc} + * + * @extends BaseWatermark */ -class Watermark implements OperationInterface +class Watermark extends BaseWatermark { - /** - * Constructor. - */ - public function __construct( - protected Gd|string $image, - protected WatermarkPosition $position = WatermarkPosition::BottomRight, - protected int $opacity = 100, - protected int $margin = 0 - ) { - if ($image instanceof Gd === false) { - $this->image = new Gd($image); - } - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Bezier.php b/src/mako/pixel/image/operations/imagemagick/Bezier.php index dd2941da6..a994b4619 100644 --- a/src/mako/pixel/image/operations/imagemagick/Bezier.php +++ b/src/mako/pixel/image/operations/imagemagick/Bezier.php @@ -10,38 +10,14 @@ use Imagick; use ImagickDraw; use ImagickPixel; -use InvalidArgumentException; -use mako\pixel\image\Color; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\geometry\Points; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Bezier as BaseBezier; use Override; -use function count; - /** - * Draws a Bézier curve on the image. + * {@inheritDoc} */ -class Bezier implements OperationInterface +class Bezier extends BaseBezier { - /** - * Constructor. - */ - public function __construct( - protected Points $points, - protected Color $stroke, - protected int $strokeWidth = 1, - protected Point $position = new Point(0, 0) - ) { - if (count($points) < 2) { - throw new InvalidArgumentException('A Bézier curve requires at least 2 points.'); - } - - if ($this->strokeWidth < 1) { - throw new InvalidArgumentException('Stroke width must be greater than 0.'); - } - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Bitonal.php b/src/mako/pixel/image/operations/imagemagick/Bitonal.php index 6df3e801d..162f836dc 100644 --- a/src/mako/pixel/image/operations/imagemagick/Bitonal.php +++ b/src/mako/pixel/image/operations/imagemagick/Bitonal.php @@ -8,13 +8,13 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Bitonal as BaseBitonal; use Override; /** - * Turns the image into bitonal. + * {@inheritDoc} */ -class Bitonal implements OperationInterface +class Bitonal extends BaseBitonal { /** * {@inheritDoc} diff --git a/src/mako/pixel/image/operations/imagemagick/Border.php b/src/mako/pixel/image/operations/imagemagick/Border.php index d9967d51a..4c04c7d3c 100644 --- a/src/mako/pixel/image/operations/imagemagick/Border.php +++ b/src/mako/pixel/image/operations/imagemagick/Border.php @@ -10,27 +10,14 @@ use Imagick; use ImagickDraw; use ImagickPixel; -use mako\pixel\image\Color; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Border as BaseBorder; use Override; -use function max; - /** - * Adds a border to the image. + * {@inheritDoc} */ -class Border implements OperationInterface +class Border extends BaseBorder { - /** - * Constructor. - */ - public function __construct( - protected Color $color = new Color(0, 0, 0), - protected int $width = 4 - ) { - $this->width = max(0, $this->width); - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Brightness.php b/src/mako/pixel/image/operations/imagemagick/Brightness.php index 61fffc49f..c82aa44fc 100644 --- a/src/mako/pixel/image/operations/imagemagick/Brightness.php +++ b/src/mako/pixel/image/operations/imagemagick/Brightness.php @@ -8,27 +8,19 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Brightness as BaseBrightness; use mako\pixel\image\operations\traits\NormalizeTrait; use Override; use function abs; /** - * Adjusts the image brightness. + * {@inheritDoc} */ -class Brightness implements OperationInterface +class Brightness extends BaseBrightness { use NormalizeTrait; - /** - * Constructor. - */ - public function __construct( - protected int $level = 0 - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Circle.php b/src/mako/pixel/image/operations/imagemagick/Circle.php index 186e1c064..7c311af63 100644 --- a/src/mako/pixel/image/operations/imagemagick/Circle.php +++ b/src/mako/pixel/image/operations/imagemagick/Circle.php @@ -10,36 +10,14 @@ use Imagick; use ImagickDraw; use ImagickPixel; -use InvalidArgumentException; -use mako\pixel\image\Color; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Circle as BaseCircle; use Override; /** - * Draws a circle on the image. + * {@inheritDoc} */ -class Circle implements OperationInterface +class Circle extends BaseCircle { - /** - * Constructor. - */ - public function __construct( - protected int $radius, - protected ?Color $fill = null, - protected ?Color $stroke = null, - protected int $strokeWidth = 1, - protected Point $center = new Point(0, 0) - ) { - if ($this->fill === null && $this->stroke === null) { - throw new InvalidArgumentException('A circle requires a fill, a stroke, or both.'); - } - - if ($this->stroke !== null && $this->strokeWidth < 1) { - throw new InvalidArgumentException('Stroke width must be greater than 0.'); - } - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/ColorSpace.php b/src/mako/pixel/image/operations/imagemagick/ColorSpace.php index 3ed8dc686..6705959db 100644 --- a/src/mako/pixel/image/operations/imagemagick/ColorSpace.php +++ b/src/mako/pixel/image/operations/imagemagick/ColorSpace.php @@ -8,9 +8,8 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use mako\pixel\image\ColorSpace as ColorSpaceEnum; use mako\pixel\image\exceptions\ImageException; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\ColorSpace as BaseColorSpace; use Override; use function constant; @@ -19,18 +18,10 @@ use function strtoupper; /** - * Transforms the color space of the image. + * {@inheritDoc} */ -class ColorSpace implements OperationInterface +class ColorSpace extends BaseColorSpace { - /** - * Constructor. - */ - public function __construct( - protected ColorSpaceEnum $colorSpace - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Colorize.php b/src/mako/pixel/image/operations/imagemagick/Colorize.php index e127fece2..91366ca2e 100644 --- a/src/mako/pixel/image/operations/imagemagick/Colorize.php +++ b/src/mako/pixel/image/operations/imagemagick/Colorize.php @@ -9,23 +9,14 @@ use Imagick; use ImagickPixel; -use mako\pixel\image\Color; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Colorize as BaseColorize; use Override; /** - * Colorizes the image. + * {@inheritDoc} */ -class Colorize implements OperationInterface +class Colorize extends BaseColorize { - /** - * Constructor. - */ - public function __construct( - protected Color $color - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Composite.php b/src/mako/pixel/image/operations/imagemagick/Composite.php index f13b47eb5..3a9367e98 100644 --- a/src/mako/pixel/image/operations/imagemagick/Composite.php +++ b/src/mako/pixel/image/operations/imagemagick/Composite.php @@ -8,22 +8,17 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use mako\pixel\image\geometry\Point; use mako\pixel\image\ImageMagick; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Composite as BaseComposite; use Override; /** - * Composites an image onto the image at the specified position. + * {@inheritDoc} + * + * @extends BaseComposite */ -class Composite implements OperationInterface +class Composite extends BaseComposite { - public function __construct( - protected ImageMagick $image, - protected Point $position = new Point(0, 0) - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Contrast.php b/src/mako/pixel/image/operations/imagemagick/Contrast.php index ad97bc2b6..93688c2ad 100644 --- a/src/mako/pixel/image/operations/imagemagick/Contrast.php +++ b/src/mako/pixel/image/operations/imagemagick/Contrast.php @@ -8,25 +8,17 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Contrast as BaseContrast; use mako\pixel\image\operations\traits\NormalizeTrait; use Override; /** - * Adjusts the image contrast. + * {@inheritDoc} */ -class Contrast implements OperationInterface +class Contrast extends BaseContrast { use NormalizeTrait; - /** - * Constructor. - */ - public function __construct( - protected int $level = 0 - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Crop.php b/src/mako/pixel/image/operations/imagemagick/Crop.php index 7df77798f..2b3f083e3 100644 --- a/src/mako/pixel/image/operations/imagemagick/Crop.php +++ b/src/mako/pixel/image/operations/imagemagick/Crop.php @@ -8,25 +8,14 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use mako\pixel\image\geometry\Dimensions; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Crop as BaseCrop; use Override; /** - * Crops the image. + * {@inheritDoc} */ -class Crop implements OperationInterface +class Crop extends BaseCrop { - /** - * Constructor. - */ - public function __construct( - protected Dimensions $dimensions, - protected Point $position - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Ellipse.php b/src/mako/pixel/image/operations/imagemagick/Ellipse.php index 2f411f963..b7e173e55 100644 --- a/src/mako/pixel/image/operations/imagemagick/Ellipse.php +++ b/src/mako/pixel/image/operations/imagemagick/Ellipse.php @@ -10,37 +10,14 @@ use Imagick; use ImagickDraw; use ImagickPixel; -use InvalidArgumentException; -use mako\pixel\image\Color; -use mako\pixel\image\geometry\Dimensions; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Ellipse as BaseEllipse; use Override; /** - * Draws an ellipse on the image. + * {@inheritDoc} */ -class Ellipse implements OperationInterface +class Ellipse extends BaseEllipse { - /** - * Constructor. - */ - public function __construct( - protected Dimensions $dimensions, - protected ?Color $fill = null, - protected ?Color $stroke = null, - protected int $strokeWidth = 1, - protected Point $center = new Point(0, 0) - ) { - if ($this->fill === null && $this->stroke === null) { - throw new InvalidArgumentException('An ellipse requires a fill, a stroke, or both.'); - } - - if ($this->stroke !== null && $this->strokeWidth < 1) { - throw new InvalidArgumentException('Stroke width must be greater than 0.'); - } - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Flip.php b/src/mako/pixel/image/operations/imagemagick/Flip.php index 9c39759ba..1bcf5fdb5 100644 --- a/src/mako/pixel/image/operations/imagemagick/Flip.php +++ b/src/mako/pixel/image/operations/imagemagick/Flip.php @@ -8,23 +8,15 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use mako\pixel\image\operations\Flip as FlipDirection; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Flip as BaseFlip; +use mako\pixel\image\operations\FlipDirection; use Override; /** - * Flips the image. + * {@inheritDoc} */ -class Flip implements OperationInterface +class Flip extends BaseFlip { - /** - * Constructor. - */ - public function __construct( - protected FlipDirection $direction = FlipDirection::Horizontal - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Gamma.php b/src/mako/pixel/image/operations/imagemagick/Gamma.php index 21b9f40e6..33caa9675 100644 --- a/src/mako/pixel/image/operations/imagemagick/Gamma.php +++ b/src/mako/pixel/image/operations/imagemagick/Gamma.php @@ -8,26 +8,14 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use InvalidArgumentException; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Gamma as BaseGamma; use Override; /** - * Adjusts the gamma level of the image. + * {@inheritDoc} */ -class Gamma implements OperationInterface +class Gamma extends BaseGamma { - /** - * Constructor. - */ - public function __construct( - protected float $gamma - ) { - if ($gamma <= 0) { - throw new InvalidArgumentException('Gamma must be greater than 0.'); - } - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Greyscale.php b/src/mako/pixel/image/operations/imagemagick/Greyscale.php index 5fc5c3bc7..cd651026e 100644 --- a/src/mako/pixel/image/operations/imagemagick/Greyscale.php +++ b/src/mako/pixel/image/operations/imagemagick/Greyscale.php @@ -8,13 +8,13 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Greyscale as BaseGreyscale; use Override; /** - * Turns the image into greyscale. + * {@inheritDoc} */ -class Greyscale implements OperationInterface +class Greyscale extends BaseGreyscale { /** * {@inheritDoc} diff --git a/src/mako/pixel/image/operations/imagemagick/Invert.php b/src/mako/pixel/image/operations/imagemagick/Invert.php index 14cda8538..d11f1bdb1 100644 --- a/src/mako/pixel/image/operations/imagemagick/Invert.php +++ b/src/mako/pixel/image/operations/imagemagick/Invert.php @@ -8,13 +8,13 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Invert as BaseInvert; use Override; /** - * Inverts the colors of the image. + * {@inheritDoc} */ -class Invert implements OperationInterface +class Invert extends BaseInvert { /** * {@inheritDoc} diff --git a/src/mako/pixel/image/operations/imagemagick/Opacity.php b/src/mako/pixel/image/operations/imagemagick/Opacity.php index f7e1f5b13..3270f6263 100644 --- a/src/mako/pixel/image/operations/imagemagick/Opacity.php +++ b/src/mako/pixel/image/operations/imagemagick/Opacity.php @@ -8,22 +8,17 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Opacity as BaseOpacity; use mako\pixel\image\operations\traits\NormalizeTrait; use Override; /** - * Adjusts the opacity of the image. + * {@inheritDoc} */ -class Opacity implements OperationInterface +class Opacity extends BaseOpacity { use NormalizeTrait; - public function __construct( - protected int $opacity - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Orient.php b/src/mako/pixel/image/operations/imagemagick/Orient.php index 8ee002ca5..96d1f8c1f 100644 --- a/src/mako/pixel/image/operations/imagemagick/Orient.php +++ b/src/mako/pixel/image/operations/imagemagick/Orient.php @@ -9,13 +9,13 @@ use Imagick; use ImagickPixel; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Orient as BaseOrient; use Override; /** - * Orients the image according to its metadata. + * {@inheritDoc} */ -class Orient implements OperationInterface +class Orient extends BaseOrient { /** * {@inheritDoc} diff --git a/src/mako/pixel/image/operations/imagemagick/Pixel.php b/src/mako/pixel/image/operations/imagemagick/Pixel.php index f20baab62..37d83575a 100644 --- a/src/mako/pixel/image/operations/imagemagick/Pixel.php +++ b/src/mako/pixel/image/operations/imagemagick/Pixel.php @@ -8,28 +8,17 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use mako\pixel\image\Color; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Pixel as BasePixel; use mako\pixel\image\traits\PixelValidationTrait; use Override; /** - * Draws a pixel on the image at the specified coordinates. + * {@inheritDoc} */ -class Pixel implements OperationInterface +class Pixel extends BasePixel { use PixelValidationTrait; - /** - * Constructor. - */ - public function __construct( - protected Point $pixel, - protected Color $color - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Pixelate.php b/src/mako/pixel/image/operations/imagemagick/Pixelate.php index 87c5685ef..288580b53 100644 --- a/src/mako/pixel/image/operations/imagemagick/Pixelate.php +++ b/src/mako/pixel/image/operations/imagemagick/Pixelate.php @@ -8,22 +8,14 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Pixelate as BasePixelate; use Override; /** - * Pixelates the image. + * {@inheritDoc} */ -class Pixelate implements OperationInterface +class Pixelate extends BasePixelate { - /** - * Constructor. - */ - public function __construct( - protected int $pixelSize = 10 - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Polygon.php b/src/mako/pixel/image/operations/imagemagick/Polygon.php index 69377413b..e74587350 100644 --- a/src/mako/pixel/image/operations/imagemagick/Polygon.php +++ b/src/mako/pixel/image/operations/imagemagick/Polygon.php @@ -10,43 +10,14 @@ use Imagick; use ImagickDraw; use ImagickPixel; -use InvalidArgumentException; -use mako\pixel\image\Color; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\geometry\Points; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Polygon as BasePolygon; use Override; -use function count; - /** - * Draws a polygon on the image. + * {@inheritDoc} */ -class Polygon implements OperationInterface +class Polygon extends BasePolygon { - /** - * Constructor. - */ - public function __construct( - protected Points $points, - protected ?Color $fill = null, - protected ?Color $stroke = null, - protected int $strokeWidth = 1, - protected Point $position = new Point(0, 0) - ) { - if (count($points) < 3) { - throw new InvalidArgumentException('A polygon requires at least 3 points.'); - } - - if ($this->fill === null && $this->stroke === null) { - throw new InvalidArgumentException('A polygon requires a fill, a stroke, or both.'); - } - - if ($this->stroke !== null && $this->strokeWidth < 1) { - throw new InvalidArgumentException('Stroke width must be greater than 0.'); - } - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Polyline.php b/src/mako/pixel/image/operations/imagemagick/Polyline.php index 0f55c69da..1f50cdf0e 100644 --- a/src/mako/pixel/image/operations/imagemagick/Polyline.php +++ b/src/mako/pixel/image/operations/imagemagick/Polyline.php @@ -10,38 +10,14 @@ use Imagick; use ImagickDraw; use ImagickPixel; -use InvalidArgumentException; -use mako\pixel\image\Color; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\geometry\Points; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Polyline as BasePolyline; use Override; -use function count; - /** - * Draws a polyline on the image. + * {@inheritDoc} */ -class Polyline implements OperationInterface +class Polyline extends BasePolyline { - /** - * Constructor. - */ - public function __construct( - protected Points $points, - protected Color $stroke, - protected int $strokeWidth = 1, - protected Point $position = new Point(0, 0) - ) { - if (count($points) < 2) { - throw new InvalidArgumentException('A polyline requires at least 2 points.'); - } - - if ($this->strokeWidth < 1) { - throw new InvalidArgumentException('Stroke width must be greater than 0.'); - } - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Rectangle.php b/src/mako/pixel/image/operations/imagemagick/Rectangle.php index 58eab675b..e763feabf 100644 --- a/src/mako/pixel/image/operations/imagemagick/Rectangle.php +++ b/src/mako/pixel/image/operations/imagemagick/Rectangle.php @@ -10,37 +10,14 @@ use Imagick; use ImagickDraw; use ImagickPixel; -use InvalidArgumentException; -use mako\pixel\image\Color; -use mako\pixel\image\geometry\Dimensions; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Rectangle as BaseRectangle; use Override; /** - * Draws a rectangle on the image. + * {@inheritDoc} */ -class Rectangle implements OperationInterface +class Rectangle extends BaseRectangle { - /** - * Constructor. - */ - public function __construct( - protected Dimensions $dimensions, - protected ?Color $fill = null, - protected ?Color $stroke = null, - protected int $strokeWidth = 1, - protected Point $position = new Point(0, 0) - ) { - if ($this->fill === null && $this->stroke === null) { - throw new InvalidArgumentException('A rectangle requires a fill, a stroke, or both.'); - } - - if ($this->stroke !== null && $this->strokeWidth < 1) { - throw new InvalidArgumentException('Stroke width must be greater than 0.'); - } - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/ReplaceColor.php b/src/mako/pixel/image/operations/imagemagick/ReplaceColor.php index 6ae77c486..8f894e2c8 100644 --- a/src/mako/pixel/image/operations/imagemagick/ReplaceColor.php +++ b/src/mako/pixel/image/operations/imagemagick/ReplaceColor.php @@ -9,29 +9,17 @@ use Imagick; use ImagickPixel; -use mako\pixel\image\Color; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\ReplaceColor as BaseReplaceColor; use Override; use function max; use function min; /** - * Replaces pixels matching a specified color with another color. + * {@inheritDoc} */ -class ReplaceColor implements OperationInterface +class ReplaceColor extends BaseReplaceColor { - /** - * Constructor. - */ - public function __construct( - protected Color $from, - protected Color $to, - protected int $tolerance = 0, - protected bool $invertMatch = false - ) { - } - /** * Converts the tolerance percentage to the active Imagick quantum range. */ diff --git a/src/mako/pixel/image/operations/imagemagick/Resize.php b/src/mako/pixel/image/operations/imagemagick/Resize.php index 5304bf673..935845117 100644 --- a/src/mako/pixel/image/operations/imagemagick/Resize.php +++ b/src/mako/pixel/image/operations/imagemagick/Resize.php @@ -8,28 +8,17 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use mako\pixel\image\geometry\Dimensions; -use mako\pixel\image\operations\AspectRatio; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Resize as BaseResize; use mako\pixel\image\operations\traits\ResizeTrait; use Override; /** - * Resizes the image. + * {@inheritDoc} */ -class Resize implements OperationInterface +class Resize extends BaseResize { use ResizeTrait; - /** - * Constructor. - */ - public function __construct( - protected Dimensions $dimensions, - protected AspectRatio $aspectRatio = AspectRatio::Auto - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Rotate.php b/src/mako/pixel/image/operations/imagemagick/Rotate.php index c2d73fad5..1bb1573dc 100644 --- a/src/mako/pixel/image/operations/imagemagick/Rotate.php +++ b/src/mako/pixel/image/operations/imagemagick/Rotate.php @@ -9,22 +9,14 @@ use Imagick; use ImagickPixel; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Rotate as BaseRotate; use Override; /** - * Rotates the image. + * {@inheritDoc} */ -class Rotate implements OperationInterface +class Rotate extends BaseRotate { - /** - * Constructor. - */ - public function __construct( - protected int $degrees = 0 - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/RoundedRectangle.php b/src/mako/pixel/image/operations/imagemagick/RoundedRectangle.php index 3ea8c0598..bbddc3ea1 100644 --- a/src/mako/pixel/image/operations/imagemagick/RoundedRectangle.php +++ b/src/mako/pixel/image/operations/imagemagick/RoundedRectangle.php @@ -10,38 +10,14 @@ use Imagick; use ImagickDraw; use ImagickPixel; -use InvalidArgumentException; -use mako\pixel\image\Color; -use mako\pixel\image\geometry\Dimensions; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\RoundedRectangle as BaseRoundedRectangle; use Override; /** - * Draws a rounded rectangle on the image. + * {@inheritDoc} */ -class RoundedRectangle implements OperationInterface +class RoundedRectangle extends BaseRoundedRectangle { - /** - * Constructor. - */ - public function __construct( - protected Dimensions $dimensions, - protected int $radius, - protected ?Color $fill = null, - protected ?Color $stroke = null, - protected int $strokeWidth = 1, - protected Point $position = new Point(0, 0) - ) { - if ($this->fill === null && $this->stroke === null) { - throw new InvalidArgumentException('A rounded rectangle requires a fill, a stroke, or both.'); - } - - if ($this->stroke !== null && $this->strokeWidth < 1) { - throw new InvalidArgumentException('Stroke width must be greater than 0.'); - } - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Saturation.php b/src/mako/pixel/image/operations/imagemagick/Saturation.php index aebd01490..1f2e94f37 100644 --- a/src/mako/pixel/image/operations/imagemagick/Saturation.php +++ b/src/mako/pixel/image/operations/imagemagick/Saturation.php @@ -8,25 +8,17 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Saturation as BaseSaturation; use mako\pixel\image\operations\traits\NormalizeTrait; use Override; /** - * Adjusts the color saturation. + * {@inheritDoc} */ -class Saturation implements OperationInterface +class Saturation extends BaseSaturation { use NormalizeTrait; - /** - * Constructor. - */ - public function __construct( - protected int $level = 0 - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Scale.php b/src/mako/pixel/image/operations/imagemagick/Scale.php index 5427633e5..1bd43b580 100644 --- a/src/mako/pixel/image/operations/imagemagick/Scale.php +++ b/src/mako/pixel/image/operations/imagemagick/Scale.php @@ -8,32 +8,16 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use InvalidArgumentException; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Scale as BaseScale; use Override; use function round; /** - * Scales the image. + * {@inheritDoc} */ -class Scale implements OperationInterface +class Scale extends BaseScale { - /** - * Constructor. - */ - public function __construct( - protected int $percent { - set(int $value) { - if ($value <= 0) { - throw new InvalidArgumentException('Scale percentage must be greater than zero.'); - } - $this->percent = $value; - } - } - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Sepia.php b/src/mako/pixel/image/operations/imagemagick/Sepia.php index 867be4e0b..5be788859 100644 --- a/src/mako/pixel/image/operations/imagemagick/Sepia.php +++ b/src/mako/pixel/image/operations/imagemagick/Sepia.php @@ -8,13 +8,13 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Sepia as BaseSepia; use Override; /** - * Turns the image into sepia. + * {@inheritDoc} */ -class Sepia implements OperationInterface +class Sepia extends BaseSepia { /** * {@inheritDoc} diff --git a/src/mako/pixel/image/operations/imagemagick/Sharpen.php b/src/mako/pixel/image/operations/imagemagick/Sharpen.php index 91a2ae420..8b371f361 100644 --- a/src/mako/pixel/image/operations/imagemagick/Sharpen.php +++ b/src/mako/pixel/image/operations/imagemagick/Sharpen.php @@ -8,13 +8,13 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Sharpen as BaseSharpen; use Override; /** - * Sharpens the image. + * {@inheritDoc} */ -class Sharpen implements OperationInterface +class Sharpen extends BaseSharpen { /** * {@inheritDoc} diff --git a/src/mako/pixel/image/operations/imagemagick/SrgbPipeline.php b/src/mako/pixel/image/operations/imagemagick/SrgbPipeline.php index 0c9cb29c6..8340854c6 100644 --- a/src/mako/pixel/image/operations/imagemagick/SrgbPipeline.php +++ b/src/mako/pixel/image/operations/imagemagick/SrgbPipeline.php @@ -8,14 +8,13 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use mako\pixel\image\operations\Pipeline; +use mako\pixel\image\operations\SrgbPipeline as BaseSrgbPipeline; use Override; /** - * Temporarily converts the image to sRGB while applying the pipelined operations, - * then restores the original color space. + * {@inheritDoc} */ -class SrgbPipeline extends Pipeline +class SrgbPipeline extends BaseSrgbPipeline { /** * {@inheritDoc} diff --git a/src/mako/pixel/image/operations/imagemagick/Temperature.php b/src/mako/pixel/image/operations/imagemagick/Temperature.php index 56d23b103..359eca5a1 100644 --- a/src/mako/pixel/image/operations/imagemagick/Temperature.php +++ b/src/mako/pixel/image/operations/imagemagick/Temperature.php @@ -8,27 +8,19 @@ namespace mako\pixel\image\operations\imagemagick; use Imagick; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Temperature as BaseTemperature; use mako\pixel\image\operations\traits\NormalizeTrait; use Override; use function abs; /** - * Adjusts the image color temperature. + * {@inheritDoc} */ -class Temperature implements OperationInterface +class Temperature extends BaseTemperature { use NormalizeTrait; - /** - * Constructor. - */ - public function __construct( - protected int $level = 0 - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Text.php b/src/mako/pixel/image/operations/imagemagick/Text.php index a8ebef67e..2d4ad64a3 100644 --- a/src/mako/pixel/image/operations/imagemagick/Text.php +++ b/src/mako/pixel/image/operations/imagemagick/Text.php @@ -10,26 +10,14 @@ use Imagick; use ImagickDraw; use ImagickPixel; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\operations\Font; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\Text as BaseText; use Override; /** - * Draws text on the image. + * {@inheritDoc} */ -class Text implements OperationInterface +class Text extends BaseText { - /** - * Constructor. - */ - public function __construct( - protected string $text, - protected Font $font, - protected Point $position, - ) { - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/TextBox.php b/src/mako/pixel/image/operations/imagemagick/TextBox.php index 8c6b12b9f..26d9642ac 100644 --- a/src/mako/pixel/image/operations/imagemagick/TextBox.php +++ b/src/mako/pixel/image/operations/imagemagick/TextBox.php @@ -10,21 +10,16 @@ use Imagick; use ImagickDraw; use ImagickPixel; -use InvalidArgumentException; -use mako\pixel\image\Color; -use mako\pixel\image\geometry\Dimensions; -use mako\pixel\image\geometry\Point; -use mako\pixel\image\operations\Font; -use mako\pixel\image\operations\OperationInterface; +use mako\pixel\image\operations\TextBox as BaseTextBox; use Override; use function count; use function explode; /** - * Draws a text box on the image. + * {@inheritDoc} */ -class TextBox implements OperationInterface +class TextBox extends BaseTextBox { /** * Metrics sample. @@ -34,23 +29,6 @@ class TextBox implements OperationInterface */ protected const string METRICS_SAMPLE = 'Ag'; - /** - * Constructor. - */ - public function __construct( - protected string $text, - protected Dimensions $dimensions, - protected Font $font, - protected ?Color $fill = null, - protected ?Color $stroke = null, - protected int $strokeWidth = 1, - protected Point $position = new Point(0, 0) - ) { - if ($this->stroke !== null && $this->strokeWidth < 1) { - throw new InvalidArgumentException('Stroke width must be greater than 0.'); - } - } - /** * {@inheritDoc} * diff --git a/src/mako/pixel/image/operations/imagemagick/Watermark.php b/src/mako/pixel/image/operations/imagemagick/Watermark.php index 6f2e8e5d1..a0f3ebdbb 100644 --- a/src/mako/pixel/image/operations/imagemagick/Watermark.php +++ b/src/mako/pixel/image/operations/imagemagick/Watermark.php @@ -10,32 +10,16 @@ use Imagick; use mako\pixel\image\geometry\Dimensions; use mako\pixel\image\ImageMagick; -use mako\pixel\image\operations\OperationInterface; -use mako\pixel\image\operations\traits\NormalizeTrait; -use mako\pixel\image\operations\WatermarkPosition; +use mako\pixel\image\operations\Watermark as BaseWatermark; use Override; /** - * Adds a watermark to the image. + * {@inheritDoc} + * + * @extends BaseWatermark */ -class Watermark implements OperationInterface +class Watermark extends BaseWatermark { - use NormalizeTrait; - - /** - * Constructor. - */ - public function __construct( - protected ImageMagick|string $image, - protected WatermarkPosition $position = WatermarkPosition::BottomRight, - protected int $opacity = 100, - protected int $margin = 0 - ) { - if ($image instanceof ImageMagick === false) { - $this->image = new ImageMagick($image); - } - } - /** * {@inheritDoc} *