public function parseSize($size)
    {
        if (ctype_alnum($size)) {
            if (preg_match('/^([0-9]{1,4})x([0-9]{1,4})$/', $size, $output)) {
                return (object) [
                    'raw'    => $output[0],
                    'method' => '{x}x{y}',
                    'x'      => intval($output[1]),
                    'y'      => intval($output[2]),
                ];
            } elseif (preg_match('/^([0-9]{1,4})o([0-9]{1,4})$/', $size, $output)) {
                return (object) [
                    'raw'    => $output[0],
                    'method' => '{x}o{y}',
                    'x'      => intval($output[1]),
                    'y'      => intval($output[2]),
                ];
            } elseif (preg_match('/^x([0-9]{1,4})$/', $size, $output)) {
                return (object) [
                    'raw'    => $output[0],
                    'method' => 'x{x}',
                    'x'      => intval($output[1]),
                ];
            } elseif (preg_match('/^y([0-9]{1,4})$/', $size, $output)) {
                return (object) [
                    'raw'    => $output[0],
                    'method' => 'y{y}',
                    'y'      => intval($output[1]),
                ];
            } else {
                dd('Illegal size. Supported: {x}x{y},{x}o{y},x{x},y{y}');
            }
        } else {
            abort(403, 'Illegal size.');
        }
    }
public function parseSize($size)
    {
        if (ctype_alnum($size)) {
            if (preg_match('/^([0-9]{1,4})x([0-9]{1,4})$/', $size, $output)) {
                return (object) [
                    'raw'    => $output[0],
                    'method' => '{x}x{y}',
                    'x'      => intval($output[1]),
                    'y'      => intval($output[2]),
                ];
            } elseif (preg_match('/^([0-9]{1,4})o([0-9]{1,4})$/', $size, $output)) {
                return (object) [
                    'raw'    => $output[0],
                    'method' => '{x}o{y}',
                    'x'      => intval($output[1]),
                    'y'      => intval($output[2]),
                ];
            } elseif (preg_match('/^x([0-9]{1,4})$/', $size, $output)) {
                return (object) [
                    'raw'    => $output[0],
                    'method' => 'x{x}',
                    'x'      => intval($output[1]),
                ];
            } elseif (preg_match('/^y([0-9]{1,4})$/', $size, $output)) {
                return (object) [
                    'raw'    => $output[0],
                    'method' => 'y{y}',
                    'y'      => intval($output[1]),
                ];
            } else {
                dd('Illegal size. Supported: {x}x{y},{x}o{y},x{x},y{y}');
            }
        } else {
            abort(403, 'Illegal size.');
        }
    }
public function parseSize ( $ size ) { if ( ctype_alnum ( $ size ) ) { if ( preg_match ( '/^([0-9]{1,4})x([0-9]{1,4})$/' , $ size , $ output ) ) { return ( object ) [ 'raw' => $ output [ 0 ] , 'method' => '{x}x{y}' , 'x' => intval ( $ output [ 1 ] ) , 'y' => intval ( $ output [ 2 ] ) , ] ; } elseif ( preg_match ( '/^([0-9]{1,4})o([0-9]{1,4})$/' , $ size , $ output ) ) { return ( object ) [ 'raw' => $ output [ 0 ] , 'method' => '{x}o{y}' , 'x' => intval ( $ output [ 1 ] ) , 'y' => intval ( $ output [ 2 ] ) , ] ; } elseif ( preg_match ( '/^x([0-9]{1,4})$/' , $ size , $ output ) ) { return ( object ) [ 'raw' => $ output [ 0 ] , 'method' => 'x{x}' , 'x' => intval ( $ output [ 1 ] ) , ] ; } elseif ( preg_match ( '/^y([0-9]{1,4})$/' , $ size , $ output ) ) { return ( object ) [ 'raw' => $ output [ 0 ] , 'method' => 'y{y}' , 'y' => intval ( $ output [ 1 ] ) , ] ; } else { dd ( 'Illegal size. Supported: {x}x{y},{x}o{y},x{x},y{y}' ) ; } } else { abort ( 403 , 'Illegal size.' ) ; } }
Check if size is correct.

Possible options:
x{x}
y{y}
{x}x{y} (fixed size)
{x}o{y} (portrait or horizontal)

@param type $size Size, for example x100, y100, 800x600, 800o600

@return type
Check if size is correct .