diff --git a/src/Drivers/Gd/Core.php b/src/Drivers/Gd/Core.php index a9aab0fa..61d0d801 100644 --- a/src/Drivers/Gd/Core.php +++ b/src/Drivers/Gd/Core.php @@ -3,6 +3,7 @@ namespace Intervention\Image\Drivers\Gd; use Intervention\Image\Collection; +use Intervention\Image\Exceptions\AnimationException; use Intervention\Image\Interfaces\CoreInterface; use Intervention\Image\Interfaces\FrameInterface; @@ -31,7 +32,13 @@ class Core extends Collection implements CoreInterface public function frame(int $position): FrameInterface { - return $this->getAtPosition($position); + $frame = $this->getAtPosition($position); + + if (!($frame instanceof FrameInterface)) { + throw new AnimationException('Frame #' . $position . ' could not be found in the image.'); + } + + return $frame; } public function loops(): int