1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-25 23:06:13 +02:00

Add exception in SliceAnimationModifier

Added again to avoid cryptic error messages.
This commit is contained in:
Oliver Vogel
2024-02-29 15:32:54 +01:00
parent 2ddcc2ceec
commit 6abba0b552
2 changed files with 10 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Intervention\Image\Drivers\Gd\Modifiers;
use Intervention\Image\Drivers\DriverSpecialized;
use Intervention\Image\Exceptions\AnimationException;
use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\ModifierInterface;
@@ -16,6 +17,10 @@ class SliceAnimationModifier extends DriverSpecialized implements ModifierInterf
{
public function apply(ImageInterface $image): ImageInterface
{
if ($this->offset >= $image->count()) {
throw new AnimationException('Offset is not in the range of frames.');
}
$image->core()->slice($this->offset, $this->length);
return $image;

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Intervention\Image\Drivers\Imagick\Modifiers;
use Intervention\Image\Drivers\DriverSpecialized;
use Intervention\Image\Exceptions\AnimationException;
use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\ModifierInterface;
@@ -16,6 +17,10 @@ class SliceAnimationModifier extends DriverSpecialized implements ModifierInterf
{
public function apply(ImageInterface $image): ImageInterface
{
if ($this->offset >= $image->count()) {
throw new AnimationException('Offset is not in the range of frames.');
}
$image->core()->slice($this->offset, $this->length);
return $image;