1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-29 16:50:07 +02:00

Add more @throws annotation (#1306)

This commit is contained in:
Vincent Langlet
2024-03-01 16:56:57 +01:00
committed by GitHub
parent 15e0167923
commit 97aa207b25
41 changed files with 230 additions and 93 deletions

View File

@@ -6,14 +6,8 @@ parameters:
check: check:
missingCheckedExceptionInThrows: true missingCheckedExceptionInThrows: true
uncheckedExceptionClasses: uncheckedExceptionClasses:
- Intervention\Image\Exceptions\AnimationException
- Intervention\Image\Exceptions\ColorException - Intervention\Image\Exceptions\ColorException
- Intervention\Image\Exceptions\DriverException
- Intervention\Image\Exceptions\GeometryException
- Intervention\Image\Exceptions\FontException
- Intervention\Image\Exceptions\InputException
- Intervention\Image\Exceptions\NotSupportedException - Intervention\Image\Exceptions\NotSupportedException
- Intervention\Image\Exceptions\NotWritableException
- ImagickException - ImagickException
- ImagickDrawException - ImagickDrawException
- ImagickPixelException - ImagickPixelException

View File

@@ -7,6 +7,7 @@ namespace Intervention\Image\Drivers;
use Exception; use Exception;
use Intervention\Image\Collection; use Intervention\Image\Collection;
use Intervention\Image\Exceptions\DecoderException; use Intervention\Image\Exceptions\DecoderException;
use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Interfaces\CollectionInterface; use Intervention\Image\Interfaces\CollectionInterface;
use Intervention\Image\Interfaces\ColorInterface; use Intervention\Image\Interfaces\ColorInterface;
use Intervention\Image\Interfaces\DecoderInterface; use Intervention\Image\Interfaces\DecoderInterface;
@@ -25,7 +26,7 @@ abstract class AbstractDecoder extends DriverSpecialized implements DecoderInter
* Try to decode given input to image or color object * Try to decode given input to image or color object
* *
* @param mixed $input * @param mixed $input
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface|ColorInterface * @return ImageInterface|ColorInterface
*/ */
final public function handle(mixed $input): ImageInterface|ColorInterface final public function handle(mixed $input): ImageInterface|ColorInterface

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Intervention\Image\Drivers; namespace Intervention\Image\Drivers;
use Intervention\Image\Exceptions\DecoderException; use Intervention\Image\Exceptions\DecoderException;
use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Interfaces\ColorInterface; use Intervention\Image\Interfaces\ColorInterface;
use Intervention\Image\Interfaces\DrawableInterface; use Intervention\Image\Interfaces\DrawableInterface;
use Intervention\Image\Interfaces\ModifierInterface; use Intervention\Image\Interfaces\ModifierInterface;
@@ -21,7 +22,7 @@ abstract class AbstractDrawModifier extends DriverSpecialized implements Modifie
} }
/** /**
* @throws DecoderException * @throws RuntimeException
*/ */
public function backgroundColor(): ColorInterface public function backgroundColor(): ColorInterface
{ {
@@ -35,7 +36,7 @@ abstract class AbstractDrawModifier extends DriverSpecialized implements Modifie
} }
/** /**
* @throws DecoderException * @throws RuntimeException
*/ */
public function borderColor(): ColorInterface public function borderColor(): ColorInterface
{ {

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Intervention\Image\Drivers; namespace Intervention\Image\Drivers;
use Intervention\Image\Exceptions\DriverException;
use Intervention\Image\Exceptions\NotSupportedException; use Intervention\Image\Exceptions\NotSupportedException;
use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Interfaces\AnalyzerInterface; use Intervention\Image\Interfaces\AnalyzerInterface;
@@ -16,6 +17,9 @@ use ReflectionClass;
abstract class AbstractDriver implements DriverInterface abstract class AbstractDriver implements DriverInterface
{ {
/**
* @throws DriverException
*/
public function __construct() public function __construct()
{ {
$this->checkHealth(); $this->checkHealth();

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Intervention\Image\Drivers; namespace Intervention\Image\Drivers;
use Intervention\Image\Exceptions\FontException;
use Intervention\Image\Geometry\Point; use Intervention\Image\Geometry\Point;
use Intervention\Image\Geometry\Rectangle; use Intervention\Image\Geometry\Rectangle;
use Intervention\Image\Interfaces\FontInterface; use Intervention\Image\Interfaces\FontInterface;
@@ -90,6 +91,7 @@ abstract class AbstractFontProcessor implements FontProcessorInterface
* *
* @param TextBlock $block * @param TextBlock $block
* @param FontInterface $font * @param FontInterface $font
* @throws FontException
* @return TextBlock * @return TextBlock
*/ */
protected function wrapTextBlock(TextBlock $block, FontInterface $font): TextBlock protected function wrapTextBlock(TextBlock $block, FontInterface $font): TextBlock
@@ -111,6 +113,7 @@ abstract class AbstractFontProcessor implements FontProcessorInterface
* *
* @param Line $line * @param Line $line
* @param FontInterface $font * @param FontInterface $font
* @throws FontException
* @return array * @return array
*/ */
protected function wrapLine(Line $line, FontInterface $font): array protected function wrapLine(Line $line, FontInterface $font): array
@@ -152,6 +155,7 @@ abstract class AbstractFontProcessor implements FontProcessorInterface
* @param TextBlock $block * @param TextBlock $block
* @param FontInterface $font * @param FontInterface $font
* @param PointInterface $position * @param PointInterface $position
* @throws FontException
* @return PointInterface * @return PointInterface
*/ */
protected function buildPivot(TextBlock $block, FontInterface $font, PointInterface $position): PointInterface protected function buildPivot(TextBlock $block, FontInterface $font, PointInterface $position): PointInterface

View File

@@ -27,6 +27,9 @@ class PixelColorAnalyzer extends DriverSpecialized implements AnalyzerInterface
); );
} }
/**
* @throws GeometryException
*/
protected function colorAt(ColorspaceInterface $colorspace, GdImage $gd): ColorInterface protected function colorAt(ColorspaceInterface $colorspace, GdImage $gd): ColorInterface
{ {
$index = @imagecolorat($gd, $this->x, $this->y); $index = @imagecolorat($gd, $this->x, $this->y);

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Intervention\Image\Drivers\Gd\Decoders; namespace Intervention\Image\Drivers\Gd\Decoders;
use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Interfaces\ColorInterface; use Intervention\Image\Interfaces\ColorInterface;
use Intervention\Image\Interfaces\DecoderInterface; use Intervention\Image\Interfaces\DecoderInterface;
use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ImageInterface;
@@ -36,7 +37,7 @@ class BinaryImageDecoder extends GdImageDecoder implements DecoderInterface
* Decode image from given binary data * Decode image from given binary data
* *
* @param string $input * @param string $input
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
private function decodeBinary(string $input): ImageInterface private function decodeBinary(string $input): ImageInterface

View File

@@ -9,6 +9,7 @@ use Intervention\Gif\Splitter as GifSplitter;
use Intervention\Image\Drivers\Gd\Core; use Intervention\Image\Drivers\Gd\Core;
use Intervention\Image\Drivers\Gd\Driver; use Intervention\Image\Drivers\Gd\Driver;
use Intervention\Image\Drivers\Gd\Frame; use Intervention\Image\Drivers\Gd\Frame;
use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Image; use Intervention\Image\Image;
use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ImageInterface;
@@ -18,6 +19,7 @@ trait CanDecodeGif
* Decode image from given GIF source which can be either a file path or binary data * Decode image from given GIF source which can be either a file path or binary data
* *
* @param mixed $input * @param mixed $input
* @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
protected function decodeGif(mixed $input): ImageInterface protected function decodeGif(mixed $input): ImageInterface

View File

@@ -5,8 +5,8 @@ declare(strict_types=1);
namespace Intervention\Image\Drivers\Gd; namespace Intervention\Image\Drivers\Gd;
use Intervention\Image\Drivers\AbstractDriver; use Intervention\Image\Drivers\AbstractDriver;
use Intervention\Image\Exceptions\DecoderException;
use Intervention\Image\Exceptions\DriverException; use Intervention\Image\Exceptions\DriverException;
use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Image; use Intervention\Image\Image;
use Intervention\Image\Interfaces\ColorInterface; use Intervention\Image\Interfaces\ColorInterface;
use Intervention\Image\Interfaces\ColorProcessorInterface; use Intervention\Image\Interfaces\ColorProcessorInterface;
@@ -81,7 +81,7 @@ class Driver extends AbstractDriver
} }
/** /**
* @throws DecoderException * @throws RuntimeException
*/ */
public function add($source, float $delay = 1): self public function add($source, float $delay = 1): self
{ {
@@ -92,6 +92,9 @@ class Driver extends AbstractDriver
return $this; return $this;
} }
/**
* @throws RuntimeException
*/
public function __invoke(): ImageInterface public function __invoke(): ImageInterface
{ {
return new Image( return new Image(

View File

@@ -9,6 +9,7 @@ use Intervention\Gif\Builder as GifBuilder;
use Intervention\Image\Drivers\DriverSpecializedEncoder; use Intervention\Image\Drivers\DriverSpecializedEncoder;
use Intervention\Image\EncodedImage; use Intervention\Image\EncodedImage;
use Intervention\Image\Exceptions\EncoderException; use Intervention\Image\Exceptions\EncoderException;
use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ImageInterface;
class GifEncoder extends DriverSpecializedEncoder class GifEncoder extends DriverSpecializedEncoder
@@ -28,7 +29,7 @@ class GifEncoder extends DriverSpecializedEncoder
} }
/** /**
* @throws EncoderException * @throws RuntimeException
*/ */
protected function encodeAnimated(ImageInterface $image): EncodedImage protected function encodeAnimated(ImageInterface $image): EncodedImage
{ {

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Intervention\Image\Drivers\Gd\Modifiers; namespace Intervention\Image\Drivers\Gd\Modifiers;
use Intervention\Image\Exceptions\GeometryException;
use Intervention\Image\Interfaces\SizeInterface; use Intervention\Image\Interfaces\SizeInterface;
/** /**
@@ -12,6 +13,9 @@ use Intervention\Image\Interfaces\SizeInterface;
*/ */
class CoverDownModifier extends CoverModifier class CoverDownModifier extends CoverModifier
{ {
/**
* @throws GeometryException
*/
public function getResizeSize(SizeInterface $size): SizeInterface public function getResizeSize(SizeInterface $size): SizeInterface
{ {
return $size->scaleDown($this->width, $this->height); return $size->scaleDown($this->width, $this->height);

View File

@@ -6,7 +6,7 @@ namespace Intervention\Image\Drivers\Gd\Modifiers;
use Intervention\Image\Drivers\DriverSpecialized; use Intervention\Image\Drivers\DriverSpecialized;
use Intervention\Image\Drivers\Gd\Frame; use Intervention\Image\Drivers\Gd\Frame;
use Intervention\Image\Exceptions\DecoderException; use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Geometry\Point; use Intervention\Image\Geometry\Point;
use Intervention\Image\Interfaces\ModifierInterface; use Intervention\Image\Interfaces\ModifierInterface;
@@ -34,7 +34,7 @@ class FillModifier extends DriverSpecialized implements ModifierInterface
} }
/** /**
* @throws DecoderException * @throws RuntimeException
*/ */
private function color(ImageInterface $image): int private function color(ImageInterface $image): int
{ {

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Intervention\Image\Drivers\Gd\Modifiers; namespace Intervention\Image\Drivers\Gd\Modifiers;
use Intervention\Image\Drivers\DriverSpecialized; use Intervention\Image\Drivers\DriverSpecialized;
use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Interfaces\FrameInterface; use Intervention\Image\Interfaces\FrameInterface;
use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\ModifierInterface; use Intervention\Image\Interfaces\ModifierInterface;
@@ -44,6 +45,7 @@ class PlaceModifier extends DriverSpecialized implements ModifierInterface
* @param FrameInterface $frame * @param FrameInterface $frame
* @param ImageInterface $watermark * @param ImageInterface $watermark
* @param PointInterface $position * @param PointInterface $position
* @throws RuntimeException
* @return void * @return void
*/ */
private function placeOpaque(FrameInterface $frame, ImageInterface $watermark, PointInterface $position): void private function placeOpaque(FrameInterface $frame, ImageInterface $watermark, PointInterface $position): void
@@ -76,6 +78,7 @@ class PlaceModifier extends DriverSpecialized implements ModifierInterface
* @param FrameInterface $frame * @param FrameInterface $frame
* @param ImageInterface $watermark * @param ImageInterface $watermark
* @param PointInterface $position * @param PointInterface $position
* @throws RuntimeException
* @return void * @return void
*/ */
private function placeTransparent(FrameInterface $frame, ImageInterface $watermark, PointInterface $position): void private function placeTransparent(FrameInterface $frame, ImageInterface $watermark, PointInterface $position): void

View File

@@ -6,6 +6,7 @@ namespace Intervention\Image\Drivers\Gd\Modifiers;
use Intervention\Image\Drivers\DriverSpecialized; use Intervention\Image\Drivers\DriverSpecialized;
use Intervention\Image\Drivers\Gd\Cloner; use Intervention\Image\Drivers\Gd\Cloner;
use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Interfaces\FrameInterface; use Intervention\Image\Interfaces\FrameInterface;
use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\ModifierInterface; use Intervention\Image\Interfaces\ModifierInterface;
@@ -50,6 +51,9 @@ class ResizeModifier extends DriverSpecialized implements ModifierInterface
$frame->setNative($modified); $frame->setNative($modified);
} }
/**
* @throws RuntimeException
*/
protected function getAdjustedSize(ImageInterface $image): SizeInterface protected function getAdjustedSize(ImageInterface $image): SizeInterface
{ {
return $image->size()->resize($this->width, $this->height); return $image->size()->resize($this->width, $this->height);

View File

@@ -7,8 +7,8 @@ namespace Intervention\Image\Drivers\Imagick;
use Imagick; use Imagick;
use ImagickPixel; use ImagickPixel;
use Intervention\Image\Drivers\AbstractDriver; use Intervention\Image\Drivers\AbstractDriver;
use Intervention\Image\Exceptions\DecoderException;
use Intervention\Image\Exceptions\DriverException; use Intervention\Image\Exceptions\DriverException;
use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Image; use Intervention\Image\Image;
use Intervention\Image\Interfaces\ColorInterface; use Intervention\Image\Interfaces\ColorInterface;
use Intervention\Image\Interfaces\ColorProcessorInterface; use Intervention\Image\Interfaces\ColorProcessorInterface;
@@ -83,7 +83,7 @@ class Driver extends AbstractDriver
} }
/** /**
* @throws DecoderException * @throws RuntimeException
*/ */
public function add($source, float $delay = 1): self public function add($source, float $delay = 1): self
{ {
@@ -95,6 +95,9 @@ class Driver extends AbstractDriver
return $this; return $this;
} }
/**
* @throws RuntimeException
*/
public function __invoke(): ImageInterface public function __invoke(): ImageInterface
{ {
return new Image( return new Image(

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Intervention\Image\Drivers\Imagick\Modifiers; namespace Intervention\Image\Drivers\Imagick\Modifiers;
use Intervention\Image\Exceptions\GeometryException;
use Intervention\Image\Interfaces\SizeInterface; use Intervention\Image\Interfaces\SizeInterface;
/** /**
@@ -12,6 +13,9 @@ use Intervention\Image\Interfaces\SizeInterface;
*/ */
class CoverDownModifier extends CoverModifier class CoverDownModifier extends CoverModifier
{ {
/**
* @throws GeometryException
*/
public function getResizeSize(SizeInterface $size): SizeInterface public function getResizeSize(SizeInterface $size): SizeInterface
{ {
return $size->scaleDown($this->width, $this->height); return $size->scaleDown($this->width, $this->height);

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Intervention\Image\Drivers\Imagick\Modifiers; namespace Intervention\Image\Drivers\Imagick\Modifiers;
use Intervention\Image\Drivers\DriverSpecialized; use Intervention\Image\Drivers\DriverSpecialized;
use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\ModifierInterface; use Intervention\Image\Interfaces\ModifierInterface;
use Intervention\Image\Interfaces\SizeInterface; use Intervention\Image\Interfaces\SizeInterface;
@@ -29,6 +30,9 @@ class ResizeModifier extends DriverSpecialized implements ModifierInterface
return $image; return $image;
} }
/**
* @throws RuntimeException
*/
protected function getAdjustedSize(ImageInterface $image): SizeInterface protected function getAdjustedSize(ImageInterface $image): SizeInterface
{ {
return $image->size()->resize($this->width, $this->height); return $image->size()->resize($this->width, $this->height);

View File

@@ -52,6 +52,7 @@ class TextModifier extends DriverSpecialized implements ModifierInterface
/** /**
* Return imagick font processor * Return imagick font processor
* *
* @throws FontException
* @return FontProcessor * @return FontProcessor
*/ */
private function processor(): FontProcessor private function processor(): FontProcessor

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Intervention\Image\Geometry; namespace Intervention\Image\Geometry;
use Intervention\Image\Exceptions\GeometryException;
use Intervention\Image\Geometry\Tools\RectangleResizer; use Intervention\Image\Geometry\Tools\RectangleResizer;
use Intervention\Image\Interfaces\PointInterface; use Intervention\Image\Interfaces\PointInterface;
use Intervention\Image\Interfaces\SizeInterface; use Intervention\Image\Interfaces\SizeInterface;
@@ -281,6 +282,9 @@ class Rectangle extends Polygon implements SizeInterface
return $this->points[2]; return $this->points[2];
} }
/**
* @throws GeometryException
*/
protected function resizer(?int $width = null, ?int $height = null): RectangleResizer protected function resizer(?int $width = null, ?int $height = null): RectangleResizer
{ {
return new RectangleResizer($width, $height); return new RectangleResizer($width, $height);

View File

@@ -10,6 +10,9 @@ use Intervention\Image\Interfaces\SizeInterface;
class RectangleResizer class RectangleResizer
{ {
/**
* @throws GeometryException
*/
public function __construct( public function __construct(
protected ?int $width = null, protected ?int $width = null,
protected ?int $height = null, protected ?int $height = null,
@@ -27,6 +30,9 @@ class RectangleResizer
} }
} }
/**
* @throws GeometryException
*/
public static function to(...$arguments): self public static function to(...$arguments): self
{ {
return new self(...$arguments); return new self(...$arguments);
@@ -52,6 +58,9 @@ class RectangleResizer
return $this->hasTargetHeight() ? $this->height : null; return $this->hasTargetHeight() ? $this->height : null;
} }
/**
* @throws GeometryException
*/
protected function getTargetSize(): SizeInterface protected function getTargetSize(): SizeInterface
{ {
if (!$this->hasTargetWidth() || !$this->hasTargetHeight()) { if (!$this->hasTargetWidth() || !$this->hasTargetHeight()) {
@@ -201,6 +210,7 @@ class RectangleResizer
* Scale given size to cover target size * Scale given size to cover target size
* *
* @param SizeInterface $size Size to be resized * @param SizeInterface $size Size to be resized
* @throws GeometryException
* @return SizeInterface * @return SizeInterface
*/ */
public function cover(SizeInterface $size): SizeInterface public function cover(SizeInterface $size): SizeInterface
@@ -224,6 +234,7 @@ class RectangleResizer
* Scale given size to contain target size * Scale given size to contain target size
* *
* @param SizeInterface $size Size to be resized * @param SizeInterface $size Size to be resized
* @throws GeometryException
* @return SizeInterface * @return SizeInterface
*/ */
public function contain(SizeInterface $size): SizeInterface public function contain(SizeInterface $size): SizeInterface
@@ -247,6 +258,7 @@ class RectangleResizer
* Scale given size to contain target size but prevent upsizing * Scale given size to contain target size but prevent upsizing
* *
* @param SizeInterface $size Size to be resized * @param SizeInterface $size Size to be resized
* @throws GeometryException
* @return SizeInterface * @return SizeInterface
*/ */
public function containDown(SizeInterface $size): SizeInterface public function containDown(SizeInterface $size): SizeInterface

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Intervention\Image; namespace Intervention\Image;
use Intervention\Image\Exceptions\RuntimeException;
use Traversable; use Traversable;
use Intervention\Image\Analyzers\ColorspaceAnalyzer; use Intervention\Image\Analyzers\ColorspaceAnalyzer;
use Intervention\Image\Analyzers\HeightAnalyzer; use Intervention\Image\Analyzers\HeightAnalyzer;
@@ -112,6 +113,7 @@ final class Image implements ImageInterface
* @param DriverInterface $driver * @param DriverInterface $driver
* @param CoreInterface $core * @param CoreInterface $core
* @param CollectionInterface $exif * @param CollectionInterface $exif
* @throws RuntimeException
* @return void * @return void
*/ */
public function __construct( public function __construct(
@@ -891,7 +893,7 @@ final class Image implements ImageInterface
* Alias of self::toJpeg() * Alias of self::toJpeg()
* *
* @param mixed $options * @param mixed $options
* @throws EncoderException * @throws RuntimeException
* @return EncodedImageInterface * @return EncodedImageInterface
*/ */
public function toJpg(mixed ...$options): EncodedImageInterface public function toJpg(mixed ...$options): EncodedImageInterface
@@ -913,7 +915,7 @@ final class Image implements ImageInterface
* ALias of self::toJpeg2000() * ALias of self::toJpeg2000()
* *
* @param mixed $options * @param mixed $options
* @throws EncoderException * @throws RuntimeException
* @return EncodedImageInterface * @return EncodedImageInterface
*/ */
public function toJp2(mixed ...$options): EncodedImageInterface public function toJp2(mixed ...$options): EncodedImageInterface
@@ -964,7 +966,7 @@ final class Image implements ImageInterface
/** /**
* Alias if self::toBitmap() * Alias if self::toBitmap()
* *
* @throws EncoderException * @throws RuntimeException
* @return EncodedImageInterface * @return EncodedImageInterface
*/ */
public function toBmp(mixed ...$options): EncodedImageInterface public function toBmp(mixed ...$options): EncodedImageInterface
@@ -996,7 +998,7 @@ final class Image implements ImageInterface
* Alias of self::toTiff() * Alias of self::toTiff()
* *
* @param mixed $options * @param mixed $options
* @throws EncoderException * @throws RuntimeException
* @return EncodedImageInterface * @return EncodedImageInterface
*/ */
public function toTif(mixed ...$options): EncodedImageInterface public function toTif(mixed ...$options): EncodedImageInterface

View File

@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Intervention\Image; namespace Intervention\Image;
use Intervention\Image\Exceptions\DecoderException; use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Interfaces\DriverInterface; use Intervention\Image\Interfaces\DriverInterface;
use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Drivers\Gd\Driver as GdDriver; use Intervention\Image\Drivers\Gd\Driver as GdDriver;
@@ -56,6 +56,7 @@ final class ImageManager
* *
* @param int $width * @param int $width
* @param int $height * @param int $height
* @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function create(int $width, int $height): ImageInterface public function create(int $width, int $height): ImageInterface
@@ -88,7 +89,7 @@ final class ImageManager
* *
* @param mixed $input * @param mixed $input
* @param string|array|DecoderInterface $decoders * @param string|array|DecoderInterface $decoders
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function read(mixed $input, string|array|DecoderInterface $decoders = []): ImageInterface public function read(mixed $input, string|array|DecoderInterface $decoders = []): ImageInterface

View File

@@ -4,12 +4,15 @@ declare(strict_types=1);
namespace Intervention\Image\Interfaces; namespace Intervention\Image\Interfaces;
use Intervention\Image\Exceptions\RuntimeException;
interface AnalyzerInterface interface AnalyzerInterface
{ {
/** /**
* Analyze given image and return the retrieved data * Analyze given image and return the retrieved data
* *
* @param ImageInterface $image * @param ImageInterface $image
* @throws RuntimeException
* @return mixed * @return mixed
*/ */
public function analyze(ImageInterface $image): mixed; public function analyze(ImageInterface $image): mixed;

View File

@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Intervention\Image\Interfaces; namespace Intervention\Image\Interfaces;
use Intervention\Image\Exceptions\DecoderException; use Intervention\Image\Exceptions\RuntimeException;
interface ColorInterface interface ColorInterface
{ {
@@ -13,7 +13,7 @@ interface ColorInterface
* and returns a corresponding color object * and returns a corresponding color object
* *
* @param mixed $input * @param mixed $input
* @throws DecoderException * @throws RuntimeException
* @return ColorInterface * @return ColorInterface
*/ */
public static function create(mixed $input): self; public static function create(mixed $input): self;

View File

@@ -4,11 +4,14 @@ declare(strict_types=1);
namespace Intervention\Image\Interfaces; namespace Intervention\Image\Interfaces;
use Intervention\Image\Exceptions\AnimationException;
interface CoreInterface extends CollectionInterface interface CoreInterface extends CollectionInterface
{ {
/** /**
* return driver's representation of the image core. * return driver's representation of the image core.
* *
* @throws AnimationException
* @return mixed * @return mixed
*/ */
public function native(): mixed; public function native(): mixed;
@@ -32,6 +35,7 @@ interface CoreInterface extends CollectionInterface
* Return frame of given position in an animated image * Return frame of given position in an animated image
* *
* @param int $position * @param int $position
* @throws AnimationException
* @return FrameInterface * @return FrameInterface
*/ */
public function frame(int $position): FrameInterface; public function frame(int $position): FrameInterface;
@@ -63,7 +67,16 @@ interface CoreInterface extends CollectionInterface
/** /**
* Get first frame in core * Get first frame in core
* *
* @throws AnimationException
* @return FrameInterface * @return FrameInterface
*/ */
public function first(): FrameInterface; public function first(): FrameInterface;
/**
* Get last frame in core
*
* @throws AnimationException
* @return FrameInterface
*/
public function last(): FrameInterface;
} }

View File

@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Intervention\Image\Interfaces; namespace Intervention\Image\Interfaces;
use Intervention\Image\Exceptions\DecoderException; use Intervention\Image\Exceptions\RuntimeException;
interface DecoderInterface interface DecoderInterface
{ {
@@ -12,7 +12,7 @@ interface DecoderInterface
* Decode given input either to color or image * Decode given input either to color or image
* *
* @param mixed $input * @param mixed $input
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface|ColorInterface * @return ImageInterface|ColorInterface
*/ */
public function decode(mixed $input): ImageInterface|ColorInterface; public function decode(mixed $input): ImageInterface|ColorInterface;

View File

@@ -4,8 +4,8 @@ declare(strict_types=1);
namespace Intervention\Image\Interfaces; namespace Intervention\Image\Interfaces;
use Intervention\Image\Exceptions\DecoderException;
use Intervention\Image\Exceptions\DriverException; use Intervention\Image\Exceptions\DriverException;
use Intervention\Image\Exceptions\RuntimeException;
interface DriverInterface interface DriverInterface
{ {
@@ -37,6 +37,7 @@ interface DriverInterface
* *
* @param int $width * @param int $width
* @param int $height * @param int $height
* @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function createImage(int $width, int $height): ImageInterface; public function createImage(int $width, int $height): ImageInterface;
@@ -54,7 +55,7 @@ interface DriverInterface
* *
* @param mixed $input * @param mixed $input
* @param array $decoders * @param array $decoders
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface|ColorInterface * @return ImageInterface|ColorInterface
*/ */
public function handleInput(mixed $input, array $decoders = []): ImageInterface|ColorInterface; public function handleInput(mixed $input, array $decoders = []): ImageInterface|ColorInterface;

View File

@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Intervention\Image\Interfaces; namespace Intervention\Image\Interfaces;
use Intervention\Image\Exceptions\EncoderException; use Intervention\Image\Exceptions\RuntimeException;
interface EncoderInterface interface EncoderInterface
{ {
@@ -12,7 +12,7 @@ interface EncoderInterface
* Encode given image * Encode given image
* *
* @param ImageInterface $image * @param ImageInterface $image
* @throws EncoderException * @throws RuntimeException
* @return EncodedImageInterface * @return EncodedImageInterface
*/ */
public function encode(ImageInterface $image): EncodedImageInterface; public function encode(ImageInterface $image): EncodedImageInterface;

View File

@@ -4,12 +4,15 @@ declare(strict_types=1);
namespace Intervention\Image\Interfaces; namespace Intervention\Image\Interfaces;
use Intervention\Image\Exceptions\RuntimeException;
interface FileInterface interface FileInterface
{ {
/** /**
* Save data in given path in file system * Save data in given path in file system
* *
* @param string $filepath * @param string $filepath
* @throws RuntimeException
* @return void * @return void
*/ */
public function save(string $filepath): void; public function save(string $filepath): void;

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Intervention\Image\Interfaces; namespace Intervention\Image\Interfaces;
use Intervention\Image\Exceptions\FontException;
use Intervention\Image\Typography\TextBlock; use Intervention\Image\Typography\TextBlock;
interface FontProcessorInterface interface FontProcessorInterface
@@ -11,6 +12,7 @@ interface FontProcessorInterface
/** /**
* Calculate size of bounding box of given text in conjuction with the given font * Calculate size of bounding box of given text in conjuction with the given font
* *
* @throws FontException
* @return SizeInterface * @return SizeInterface
*/ */
public function boxSize(string $text, FontInterface $font): SizeInterface; public function boxSize(string $text, FontInterface $font): SizeInterface;
@@ -22,6 +24,7 @@ interface FontProcessorInterface
* @param string $text * @param string $text
* @param FontInterface $font * @param FontInterface $font
* @param PointInterface $position * @param PointInterface $position
* @throws FontException
* @return TextBlock * @return TextBlock
*/ */
public function textBlock(string $text, FontInterface $font, PointInterface $position): TextBlock; public function textBlock(string $text, FontInterface $font, PointInterface $position): TextBlock;
@@ -36,6 +39,7 @@ interface FontProcessorInterface
/** /**
* Calculate the typographical font size in pixels * Calculate the typographical font size in pixels
* *
* @throws FontException
* @return int * @return int
*/ */
public function typographicalSize(FontInterface $font): int; public function typographicalSize(FontInterface $font): int;
@@ -44,6 +48,7 @@ interface FontProcessorInterface
* Calculates typographical cap height * Calculates typographical cap height
* *
* @param FontInterface $font * @param FontInterface $font
* @throws FontException
* @return int * @return int
*/ */
public function capHeight(FontInterface $font): int; public function capHeight(FontInterface $font): int;
@@ -52,6 +57,7 @@ interface FontProcessorInterface
* Calculates typographical leading size * Calculates typographical leading size
* *
* @param FontInterface $font * @param FontInterface $font
* @throws FontException
* @return int * @return int
*/ */
public function leading(FontInterface $font): int; public function leading(FontInterface $font): int;

View File

@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Intervention\Image\Interfaces; namespace Intervention\Image\Interfaces;
use Intervention\Image\Exceptions\RuntimeException;
interface FrameInterface interface FrameInterface
{ {
/** /**
@@ -25,6 +27,7 @@ interface FrameInterface
* Transform frame into an image * Transform frame into an image
* *
* @param DriverInterface $driver * @param DriverInterface $driver
* @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function toImage(DriverInterface $driver): ImageInterface; public function toImage(DriverInterface $driver): ImageInterface;

View File

@@ -6,8 +6,7 @@ namespace Intervention\Image\Interfaces;
use Countable; use Countable;
use Intervention\Image\Encoders\AutoEncoder; use Intervention\Image\Encoders\AutoEncoder;
use Intervention\Image\Exceptions\DecoderException; use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Exceptions\EncoderException;
use Intervention\Image\Origin; use Intervention\Image\Origin;
use IteratorAggregate; use IteratorAggregate;
@@ -45,6 +44,7 @@ interface ImageInterface extends IteratorAggregate, Countable
/** /**
* Return width of current image * Return width of current image
* *
* @throws RuntimeException
* @return int * @return int
*/ */
public function width(): int; public function width(): int;
@@ -52,6 +52,7 @@ interface ImageInterface extends IteratorAggregate, Countable
/** /**
* Return height of current image * Return height of current image
* *
* @throws RuntimeException
* @return int * @return int
*/ */
public function height(): int; public function height(): int;
@@ -59,6 +60,7 @@ interface ImageInterface extends IteratorAggregate, Countable
/** /**
* Return size of current image * Return size of current image
* *
* @throws RuntimeException
* @return SizeInterface * @return SizeInterface
*/ */
public function size(): SizeInterface; public function size(): SizeInterface;
@@ -67,7 +69,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image with given encoder * Encode image with given encoder
* *
* @param EncoderInterface $encoder * @param EncoderInterface $encoder
* @throws EncoderException * @throws RuntimeException
* @return EncodedImageInterface * @return EncodedImageInterface
*/ */
public function encode(EncoderInterface $encoder = new AutoEncoder()): EncodedImageInterface; public function encode(EncoderInterface $encoder = new AutoEncoder()): EncodedImageInterface;
@@ -77,7 +79,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* given, the image will be saved at its original location. * given, the image will be saved at its original location.
* *
* @param null|string $path * @param null|string $path
* @throws EncoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function save(?string $path = null, ...$options): self; public function save(?string $path = null, ...$options): self;
@@ -86,7 +88,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Apply given modifier to current image * Apply given modifier to current image
* *
* @param ModifierInterface $modifier * @param ModifierInterface $modifier
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function modify(ModifierInterface $modifier): self; public function modify(ModifierInterface $modifier): self;
@@ -95,6 +97,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Analyzer current image with given analyzer * Analyzer current image with given analyzer
* *
* @param AnalyzerInterface $analyzer * @param AnalyzerInterface $analyzer
* @throws RuntimeException
* @return mixed * @return mixed
*/ */
public function analyze(AnalyzerInterface $analyzer): mixed; public function analyze(AnalyzerInterface $analyzer): mixed;
@@ -115,7 +118,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* and the respective frame position is only determined approximately. * and the respective frame position is only determined approximately.
* *
* @param int|string $position * @param int|string $position
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function removeAnimation(int|string $position = 0): self; public function removeAnimation(int|string $position = 0): self;
@@ -125,7 +128,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* *
* @param int $offset * @param int $offset
* @param null|int $length * @param null|int $length
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function sliceAnimation(int $offset = 0, ?int $length = null): self; public function sliceAnimation(int $offset = 0, ?int $length = null): self;
@@ -163,6 +166,7 @@ interface ImageInterface extends IteratorAggregate, Countable
/** /**
* Return image resolution/density * Return image resolution/density
* *
* @throws RuntimeException
* @return ResolutionInterface * @return ResolutionInterface
*/ */
public function resolution(): ResolutionInterface; public function resolution(): ResolutionInterface;
@@ -172,7 +176,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* *
* @param float $x * @param float $x
* @param float $y * @param float $y
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function setResolution(float $x, float $y): self; public function setResolution(float $x, float $y): self;
@@ -180,6 +184,7 @@ interface ImageInterface extends IteratorAggregate, Countable
/** /**
* Get the colorspace of the image * Get the colorspace of the image
* *
* @throws RuntimeException
* @return ColorspaceInterface * @return ColorspaceInterface
*/ */
public function colorspace(): ColorspaceInterface; public function colorspace(): ColorspaceInterface;
@@ -188,7 +193,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Transform image to given colorspace * Transform image to given colorspace
* *
* @param string|ColorspaceInterface $colorspace * @param string|ColorspaceInterface $colorspace
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function setColorspace(string|ColorspaceInterface $colorspace): self; public function setColorspace(string|ColorspaceInterface $colorspace): self;
@@ -199,6 +204,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $x * @param int $x
* @param int $y * @param int $y
* @param int $frame_key * @param int $frame_key
* @throws RuntimeException
* @return ColorInterface * @return ColorInterface
*/ */
public function pickColor(int $x, int $y, int $frame_key = 0): ColorInterface; public function pickColor(int $x, int $y, int $frame_key = 0): ColorInterface;
@@ -208,6 +214,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* *
* @param int $x * @param int $x
* @param int $y * @param int $y
* @throws RuntimeException
* @return CollectionInterface * @return CollectionInterface
*/ */
public function pickColors(int $x, int $y): CollectionInterface; public function pickColors(int $x, int $y): CollectionInterface;
@@ -225,7 +232,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* which does not support transparency. * which does not support transparency.
* *
* @param mixed $color * @param mixed $color
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function setBlendingColor(mixed $color): self; public function setBlendingColor(mixed $color): self;
@@ -234,7 +241,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Replace transparent areas of the image with given color * Replace transparent areas of the image with given color
* *
* @param mixed $color * @param mixed $color
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function blendTransparency(mixed $color = null): self; public function blendTransparency(mixed $color = null): self;
@@ -242,6 +249,7 @@ interface ImageInterface extends IteratorAggregate, Countable
/** /**
* Retrieve ICC color profile of image * Retrieve ICC color profile of image
* *
* @throws RuntimeException
* @return ProfileInterface * @return ProfileInterface
*/ */
public function profile(): ProfileInterface; public function profile(): ProfileInterface;
@@ -250,7 +258,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Set given icc color profile to image * Set given icc color profile to image
* *
* @param ProfileInterface $profile * @param ProfileInterface $profile
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function setProfile(ProfileInterface $profile): self; public function setProfile(ProfileInterface $profile): self;
@@ -258,7 +266,7 @@ interface ImageInterface extends IteratorAggregate, Countable
/** /**
* Remove ICC color profile from the current image * Remove ICC color profile from the current image
* *
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function removeProfile(): self; public function removeProfile(): self;
@@ -268,7 +276,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* *
* @param int $limit * @param int $limit
* @param mixed $background * @param mixed $background
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function reduceColors(int $limit, mixed $background = 'transparent'): self; public function reduceColors(int $limit, mixed $background = 'transparent'): self;
@@ -277,7 +285,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Sharpen the current image with given strength * Sharpen the current image with given strength
* *
* @param int $amount * @param int $amount
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function sharpen(int $amount = 10): self; public function sharpen(int $amount = 10): self;
@@ -285,7 +293,7 @@ interface ImageInterface extends IteratorAggregate, Countable
/** /**
* Turn image into a greyscale version * Turn image into a greyscale version
* *
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function greyscale(): self; public function greyscale(): self;
@@ -294,7 +302,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Adjust brightness of the current image * Adjust brightness of the current image
* *
* @param int $level * @param int $level
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function brightness(int $level): self; public function brightness(int $level): self;
@@ -303,7 +311,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Adjust color contrast of the current image * Adjust color contrast of the current image
* *
* @param int $level * @param int $level
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function contrast(int $level): self; public function contrast(int $level): self;
@@ -312,7 +320,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Apply gamma correction on the current image * Apply gamma correction on the current image
* *
* @param float $gamma * @param float $gamma
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function gamma(float $gamma): self; public function gamma(float $gamma): self;
@@ -323,7 +331,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $red * @param int $red
* @param int $green * @param int $green
* @param int $blue * @param int $blue
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function colorize(int $red = 0, int $green = 0, int $blue = 0): self; public function colorize(int $red = 0, int $green = 0, int $blue = 0): self;
@@ -331,7 +339,7 @@ interface ImageInterface extends IteratorAggregate, Countable
/** /**
* Mirror the current image horizontally * Mirror the current image horizontally
* *
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function flip(): self; public function flip(): self;
@@ -339,7 +347,7 @@ interface ImageInterface extends IteratorAggregate, Countable
/** /**
* Mirror the current image vertically * Mirror the current image vertically
* *
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function flop(): self; public function flop(): self;
@@ -348,7 +356,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Blur current image by given strength * Blur current image by given strength
* *
* @param int $amount * @param int $amount
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function blur(int $amount = 5): self; public function blur(int $amount = 5): self;
@@ -356,7 +364,7 @@ interface ImageInterface extends IteratorAggregate, Countable
/** /**
* Invert the colors of the current image * Invert the colors of the current image
* *
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function invert(): self; public function invert(): self;
@@ -365,7 +373,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Apply pixelation filter effect on current image * Apply pixelation filter effect on current image
* *
* @param int $size * @param int $size
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function pixelate(int $size): self; public function pixelate(int $size): self;
@@ -375,7 +383,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* *
* @param float $angle * @param float $angle
* @param string $background * @param string $background
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function rotate(float $angle, mixed $background = 'ffffff'): self; public function rotate(float $angle, mixed $background = 'ffffff'): self;
@@ -387,7 +395,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $x * @param int $x
* @param int $y * @param int $y
* @param callable|FontInterface $font * @param callable|FontInterface $font
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function text(string $text, int $x, int $y, callable|FontInterface $font): self; public function text(string $text, int $x, int $y, callable|FontInterface $font): self;
@@ -397,7 +405,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* *
* @param null|int $width * @param null|int $width
* @param null|int $height * @param null|int $height
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function resize(?int $width = null, ?int $height = null): self; public function resize(?int $width = null, ?int $height = null): self;
@@ -407,7 +415,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* *
* @param null|int $width * @param null|int $width
* @param null|int $height * @param null|int $height
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function resizeDown(?int $width = null, ?int $height = null): self; public function resizeDown(?int $width = null, ?int $height = null): self;
@@ -417,7 +425,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* *
* @param null|int $width * @param null|int $width
* @param null|int $height * @param null|int $height
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function scale(?int $width = null, ?int $height = null): self; public function scale(?int $width = null, ?int $height = null): self;
@@ -428,7 +436,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* *
* @param null|int $width * @param null|int $width
* @param null|int $height * @param null|int $height
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function scaleDown(?int $width = null, ?int $height = null): self; public function scaleDown(?int $width = null, ?int $height = null): self;
@@ -441,7 +449,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $width * @param int $width
* @param int $height * @param int $height
* @param string $position * @param string $position
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function cover(int $width, int $height, string $position = 'center'): self; public function cover(int $width, int $height, string $position = 'center'): self;
@@ -452,7 +460,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $width * @param int $width
* @param int $height * @param int $height
* @param string $position * @param string $position
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function coverDown(int $width, int $height, string $position = 'center'): self; public function coverDown(int $width, int $height, string $position = 'center'): self;
@@ -467,7 +475,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param null|int $height * @param null|int $height
* @param string $position * @param string $position
* @param mixed $background * @param mixed $background
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function resizeCanvas( public function resizeCanvas(
@@ -486,7 +494,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param null|int $height * @param null|int $height
* @param string $position * @param string $position
* @param mixed $background * @param mixed $background
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function resizeCanvasRelative( public function resizeCanvasRelative(
@@ -509,7 +517,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $height * @param int $height
* @param string $background * @param string $background
* @param string $position * @param string $position
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function pad( public function pad(
@@ -527,7 +535,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $height * @param int $height
* @param string $background * @param string $background
* @param string $position * @param string $position
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function contain( public function contain(
@@ -548,7 +556,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $offset_y * @param int $offset_y
* @param mixed $background * @param mixed $background
* @param string $position * @param string $position
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function crop( public function crop(
@@ -568,7 +576,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $offset_x * @param int $offset_x
* @param int $offset_y * @param int $offset_y
* @param int $opacity * @param int $opacity
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function place( public function place(
@@ -592,7 +600,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param mixed $color * @param mixed $color
* @param null|int $x * @param null|int $x
* @param null|int $y * @param null|int $y
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function fill(mixed $color, ?int $x = null, ?int $y = null): self; public function fill(mixed $color, ?int $x = null, ?int $y = null): self;
@@ -603,7 +611,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $x * @param int $x
* @param int $y * @param int $y
* @param mixed $color * @param mixed $color
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function drawPixel(int $x, int $y, mixed $color): self; public function drawPixel(int $x, int $y, mixed $color): self;
@@ -614,7 +622,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $x * @param int $x
* @param int $y * @param int $y
* @param callable $init * @param callable $init
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function drawRectangle(int $x, int $y, callable $init): self; public function drawRectangle(int $x, int $y, callable $init): self;
@@ -625,7 +633,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $x * @param int $x
* @param int $y * @param int $y
* @param callable $init * @param callable $init
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function drawEllipse(int $x, int $y, callable $init): self; public function drawEllipse(int $x, int $y, callable $init): self;
@@ -636,7 +644,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $x * @param int $x
* @param int $y * @param int $y
* @param callable $init * @param callable $init
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function drawCircle(int $x, int $y, callable $init): self; public function drawCircle(int $x, int $y, callable $init): self;
@@ -645,7 +653,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Draw a polygon on the current image * Draw a polygon on the current image
* *
* @param callable $init * @param callable $init
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function drawPolygon(callable $init): self; public function drawPolygon(callable $init): self;
@@ -654,7 +662,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Draw a line on the current image * Draw a line on the current image
* *
* @param callable $init * @param callable $init
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function drawLine(callable $init): self; public function drawLine(callable $init): self;
@@ -664,7 +672,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* will be encoded to the format of the originally read image. * will be encoded to the format of the originally read image.
* *
* @param null|string $type * @param null|string $type
* @throws EncoderException * @throws RuntimeException
* @return EncodedImageInterface * @return EncodedImageInterface
*/ */
public function encodeByMediaType(?string $type = null, ...$options): EncodedImageInterface; public function encodeByMediaType(?string $type = null, ...$options): EncodedImageInterface;
@@ -675,7 +683,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* originally read image. * originally read image.
* *
* @param null|string $extension * @param null|string $extension
* @throws EncoderException * @throws RuntimeException
* @return EncodedImageInterface * @return EncodedImageInterface
*/ */
public function encodeByExtension(?string $extension = null, mixed ...$options): EncodedImageInterface; public function encodeByExtension(?string $extension = null, mixed ...$options): EncodedImageInterface;
@@ -686,7 +694,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* the format of the originally read image. * the format of the originally read image.
* *
* @param null|string $path * @param null|string $path
* @throws EncoderException * @throws RuntimeException
* @return EncodedImageInterface * @return EncodedImageInterface
*/ */
public function encodeByPath(?string $path = null, mixed ...$options): EncodedImageInterface; public function encodeByPath(?string $path = null, mixed ...$options): EncodedImageInterface;
@@ -695,7 +703,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image to JPEG format * Encode image to JPEG format
* *
* @param mixed $options * @param mixed $options
* @throws EncoderException * @throws RuntimeException
* @return EncodedImageInterface * @return EncodedImageInterface
*/ */
@@ -705,7 +713,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image to Jpeg2000 format * Encode image to Jpeg2000 format
* *
* @param mixed $options * @param mixed $options
* @throws EncoderException * @throws RuntimeException
* @return EncodedImageInterface * @return EncodedImageInterface
*/ */
public function toJpeg2000(mixed ...$options): EncodedImageInterface; public function toJpeg2000(mixed ...$options): EncodedImageInterface;
@@ -714,7 +722,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image to Webp format * Encode image to Webp format
* *
* @param mixed $options * @param mixed $options
* @throws EncoderException * @throws RuntimeException
* @return EncodedImageInterface * @return EncodedImageInterface
*/ */
public function toWebp(mixed ...$options): EncodedImageInterface; public function toWebp(mixed ...$options): EncodedImageInterface;
@@ -723,7 +731,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image to PNG format * Encode image to PNG format
* *
* @param mixed $options * @param mixed $options
* @throws EncoderException * @throws RuntimeException
* @return EncodedImageInterface * @return EncodedImageInterface
*/ */
public function toPng(mixed ...$options): EncodedImageInterface; public function toPng(mixed ...$options): EncodedImageInterface;
@@ -732,7 +740,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image to GIF format * Encode image to GIF format
* *
* @param mixed $options * @param mixed $options
* @throws EncoderException * @throws RuntimeException
* @return EncodedImageInterface * @return EncodedImageInterface
*/ */
public function toGif(mixed ...$options): EncodedImageInterface; public function toGif(mixed ...$options): EncodedImageInterface;
@@ -741,7 +749,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image to Bitmap format * Encode image to Bitmap format
* *
* @param mixed $options * @param mixed $options
* @throws EncoderException * @throws RuntimeException
* @return EncodedImageInterface * @return EncodedImageInterface
*/ */
public function toBitmap(mixed ...$options): EncodedImageInterface; public function toBitmap(mixed ...$options): EncodedImageInterface;
@@ -750,7 +758,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image to AVIF format * Encode image to AVIF format
* *
* @param mixed $options * @param mixed $options
* @throws EncoderException * @throws RuntimeException
* @return EncodedImageInterface * @return EncodedImageInterface
*/ */
public function toAvif(mixed ...$options): EncodedImageInterface; public function toAvif(mixed ...$options): EncodedImageInterface;
@@ -759,7 +767,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image to TIFF format * Encode image to TIFF format
* *
* @param mixed $options * @param mixed $options
* @throws EncoderException * @throws RuntimeException
* @return EncodedImageInterface * @return EncodedImageInterface
*/ */
public function toTiff(mixed ...$options): EncodedImageInterface; public function toTiff(mixed ...$options): EncodedImageInterface;
@@ -768,7 +776,7 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image to HEIC format * Encode image to HEIC format
* *
* @param mixed $options * @param mixed $options
* @throws EncoderException * @throws RuntimeException
* @return EncodedImageInterface * @return EncodedImageInterface
*/ */
public function toHeic(mixed ...$options): EncodedImageInterface; public function toHeic(mixed ...$options): EncodedImageInterface;

View File

@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Intervention\Image\Interfaces; namespace Intervention\Image\Interfaces;
use Intervention\Image\Exceptions\DecoderException; use Intervention\Image\Exceptions\RuntimeException;
interface InputHandlerInterface interface InputHandlerInterface
{ {
@@ -12,7 +12,7 @@ interface InputHandlerInterface
* Try to decode the given input with each decoder of the the handler chain * Try to decode the given input with each decoder of the the handler chain
* *
* @param mixed $input * @param mixed $input
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface|ColorInterface * @return ImageInterface|ColorInterface
*/ */
public function handle($input): ImageInterface|ColorInterface; public function handle($input): ImageInterface|ColorInterface;

View File

@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Intervention\Image\Interfaces; namespace Intervention\Image\Interfaces;
use Intervention\Image\Exceptions\DecoderException; use Intervention\Image\Exceptions\RuntimeException;
interface ModifierInterface interface ModifierInterface
{ {
@@ -12,7 +12,7 @@ interface ModifierInterface
* Apply modifications of the current modifier to the given image * Apply modifications of the current modifier to the given image
* *
* @param ImageInterface $image * @param ImageInterface $image
* @throws DecoderException * @throws RuntimeException
* @return ImageInterface * @return ImageInterface
*/ */
public function apply(ImageInterface $image): ImageInterface; public function apply(ImageInterface $image): ImageInterface;

View File

@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Intervention\Image\Interfaces; namespace Intervention\Image\Interfaces;
use Intervention\Image\Exceptions\GeometryException;
interface SizeInterface interface SizeInterface
{ {
/** /**
@@ -110,33 +112,48 @@ interface SizeInterface
/** /**
* @see ImageInterface::resize() * @see ImageInterface::resize()
*
* @throws GeometryException
*/ */
public function resize(?int $width = null, ?int $height = null): self; public function resize(?int $width = null, ?int $height = null): self;
/** /**
* @see ImageInterface::resizeDown() * @see ImageInterface::resizeDown()
*
* @throws GeometryException
*/ */
public function resizeDown(?int $width = null, ?int $height = null): self; public function resizeDown(?int $width = null, ?int $height = null): self;
/** /**
* @see ImageInterface::scale() * @see ImageInterface::scale()
*
* @throws GeometryException
*/ */
public function scale(?int $width = null, ?int $height = null): self; public function scale(?int $width = null, ?int $height = null): self;
/** /**
* @see ImageInterface::scaleDown() * @see ImageInterface::scaleDown()
*
* @throws GeometryException
*/ */
public function scaleDown(?int $width = null, ?int $height = null): self; public function scaleDown(?int $width = null, ?int $height = null): self;
/** /**
* @see ImageInterface::cover() * @see ImageInterface::cover()
*
* @throws GeometryException
*/ */
public function cover(int $width, int $height): self; public function cover(int $width, int $height): self;
/** /**
* @see ImageInterface::contain() * @see ImageInterface::contain()
*
* @throws GeometryException
*/ */
public function contain(int $width, int $height): self; public function contain(int $width, int $height): self;
/**
* @throws GeometryException
*/
public function containMax(int $width, int $height): self; public function containMax(int $width, int $height): self;
} }

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Intervention\Image\Modifiers; namespace Intervention\Image\Modifiers;
use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Geometry\Rectangle; use Intervention\Image\Geometry\Rectangle;
use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\SizeInterface; use Intervention\Image\Interfaces\SizeInterface;
@@ -18,6 +19,9 @@ class ContainModifier extends SpecializableModifier
) { ) {
} }
/**
* @throws RuntimeException
*/
public function getCropSize(ImageInterface $image): SizeInterface public function getCropSize(ImageInterface $image): SizeInterface
{ {
return $image->size() return $image->size()

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Intervention\Image\Modifiers; namespace Intervention\Image\Modifiers;
use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Geometry\Rectangle; use Intervention\Image\Geometry\Rectangle;
use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\SizeInterface; use Intervention\Image\Interfaces\SizeInterface;
@@ -17,6 +18,9 @@ class CoverModifier extends SpecializableModifier
) { ) {
} }
/**
* @throws RuntimeException
*/
public function getCropSize(ImageInterface $image): SizeInterface public function getCropSize(ImageInterface $image): SizeInterface
{ {
$imagesize = $image->size(); $imagesize = $image->size();
@@ -30,6 +34,9 @@ class CoverModifier extends SpecializableModifier
return $crop; return $crop;
} }
/**
* @throws RuntimeException
*/
public function getResizeSize(SizeInterface $size): SizeInterface public function getResizeSize(SizeInterface $size): SizeInterface
{ {
return $size->scale($this->width, $this->height); return $size->scale($this->width, $this->height);

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Intervention\Image\Modifiers; namespace Intervention\Image\Modifiers;
use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Geometry\Rectangle; use Intervention\Image\Geometry\Rectangle;
use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\SizeInterface; use Intervention\Image\Interfaces\SizeInterface;
@@ -20,6 +21,9 @@ class CropModifier extends SpecializableModifier
) { ) {
} }
/**
* @throws RuntimeException
*/
public function crop(ImageInterface $image): SizeInterface public function crop(ImageInterface $image): SizeInterface
{ {
$crop = new Rectangle($this->width, $this->height); $crop = new Rectangle($this->width, $this->height);

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Intervention\Image\Modifiers; namespace Intervention\Image\Modifiers;
use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\PointInterface; use Intervention\Image\Interfaces\PointInterface;
@@ -18,6 +19,9 @@ class PlaceModifier extends SpecializableModifier
) { ) {
} }
/**
* @throws RuntimeException
*/
public function getPosition(ImageInterface $image, ImageInterface $watermark): PointInterface public function getPosition(ImageInterface $image, ImageInterface $watermark): PointInterface
{ {
$image_size = $image->size()->movePivot( $image_size = $image->size()->movePivot(

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Intervention\Image\Modifiers; namespace Intervention\Image\Modifiers;
use Intervention\Image\Exceptions\InputException; use Intervention\Image\Exceptions\InputException;
use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Interfaces\FrameInterface; use Intervention\Image\Interfaces\FrameInterface;
use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ImageInterface;
@@ -15,6 +16,9 @@ class RemoveAnimationModifier extends SpecializableModifier
// //
} }
/**
* @throws RuntimeException
*/
public function chosenFrame(ImageInterface $image, int|string $position): FrameInterface public function chosenFrame(ImageInterface $image, int|string $position): FrameInterface
{ {
if (is_int($position)) { if (is_int($position)) {

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Intervention\Image\Modifiers; namespace Intervention\Image\Modifiers;
use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Geometry\Rectangle; use Intervention\Image\Geometry\Rectangle;
use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\SizeInterface; use Intervention\Image\Interfaces\SizeInterface;
@@ -18,6 +19,9 @@ class ResizeCanvasModifier extends SpecializableModifier
) { ) {
} }
/**
* @throws RuntimeException
*/
public function cropSize(ImageInterface $image): SizeInterface public function cropSize(ImageInterface $image): SizeInterface
{ {
$width = is_null($this->width) ? $image->width() : $this->width; $width = is_null($this->width) ? $image->width() : $this->width;