core()->frame($position); } if (preg_match("/^(?P[0-9]{1,3})%$/", $position, $matches) != 1) { throw new InputException( 'Position must be either integer or a percent value as string.' ); } $total = count($image); $position = intval(round($total / 100 * intval($matches['percent']))); $position = $position == $total ? $position - 1 : $position; return $image->core()->frame($position); } }