Skip to content

Commit

Permalink
Move code to try catch block
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Dec 31, 2024
1 parent de4c7a6 commit 15b1e4b
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,24 @@ public function frame(int $position): FrameInterface
throw new AnimationException('Frame #' . $position . ' could not be found in the image.');
}

$height = $this->vipsImage->getType('page-height') === 0 ?
$this->vipsImage->height : $this->vipsImage->get('page-height');

// extract only certain frame
$vipsImage = $this->vipsImage->extract_area(
0,
$height * $position,
$this->vipsImage->width,
$height
);

$vipsImage->set('n-pages', 1);

try {
return new Frame($vipsImage);
} catch (Exception) {
$height = $this->vipsImage->getType('page-height') === 0 ?
$this->vipsImage->height : $this->vipsImage->get('page-height');

// extract only certain frame
$vipsImage = $this->vipsImage->extract_area(
0,
$height * $position,
$this->vipsImage->width,
$height
);

$vipsImage->set('n-pages', 1);
} catch (VipsException) {
throw new AnimationException('Frame #' . $position . ' could not be found in the image.');
}

return new Frame($vipsImage);
}

/**
Expand Down

0 comments on commit 15b1e4b

Please sign in to comment.