diff --git a/src/Drivers/Imagick/Core.php b/src/Drivers/Imagick/Core.php index 6840e8f0..4e00d3cc 100644 --- a/src/Drivers/Imagick/Core.php +++ b/src/Drivers/Imagick/Core.php @@ -7,6 +7,7 @@ use ImagickException; use Iterator; use Intervention\Image\Interfaces\CoreInterface; use Intervention\Image\Exceptions\AnimationException; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Interfaces\CollectionInterface; use Intervention\Image\Interfaces\FrameInterface; @@ -89,6 +90,10 @@ class Core implements CoreInterface, Iterator */ public function slice(int $offset, ?int $length = null): CollectionInterface { + if ($offset >= $this->count()) { + throw new RuntimeException('Offset exceeds the maximum value.'); + } + $allowed_indexes = []; $length = is_null($length) ? $this->count() : $length; for ($i = $offset; $i < $offset + $length; $i++) {