def _compute_resized_shape(from_shape, to_shape):
if is_np_array(from_shape):<EOL><INDENT>from_shape = from_shape.shape<EOL><DEDENT>if is_np_array(to_shape):<EOL><INDENT>to_shape = to_shape.shape<EOL><DEDENT>to_shape_computed = list(from_shape)<EOL>if to_shape is None:<EOL><INDENT>pass<EOL><DEDENT>elif isinstance(to_shape, tuple):<EOL><INDENT>do_assert(len(from_shape) in [<NUM_LIT:2>, <NUM_LIT:3>])<EOL>do_assert(len(to_shape) in [<NUM_LIT:2>, <NUM_LIT:3>])<EOL>if len(from_shape) == <NUM_LIT:3> and len(to_shape) == <NUM_LIT:3>:<EOL><INDENT>do_assert(from_shape[<NUM_LIT:2>] == to_shape[<NUM_LIT:2>])<EOL><DEDENT>elif len(to_shape) == <NUM_LIT:3>:<EOL><INDENT>to_shape_computed.append(to_shape[<NUM_LIT:2>])<EOL><DEDENT>do_assert(all([v is None or is_single_number(v) for v in to_shape[<NUM_LIT:0>:<NUM_LIT:2>]]),<EOL>"<STR_LIT>"<EOL>+ "<STR_LIT>" % (str([type(v) for v in to_shape[<NUM_LIT:0>:<NUM_LIT:2>]]),))<EOL>for i, from_shape_i in enumerate(from_shape[<NUM_LIT:0>:<NUM_LIT:2>]):<EOL><INDENT>if to_shape[i] is None:<EOL><INDENT>to_shape_computed[i] = from_shape_i<EOL><DEDENT>elif is_single_integer(to_shape[i]):<EOL><INDENT>to_shape_computed[i] = to_shape[i]<EOL><DEDENT>else:  <EOL><INDENT>to_shape_computed[i] = int(np.round(from_shape_i * to_shape[i]))<EOL><DEDENT><DEDENT><DEDENT>elif is_single_integer(to_shape) or is_single_float(to_shape):<EOL><INDENT>to_shape_computed = _compute_resized_shape(from_shape, (to_shape, to_shape))<EOL><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>"<EOL>+ "<STR_LIT>" % (type(to_shape),))<EOL><DEDENT>return tuple(to_shape_computed)<EOL>
Computes the intended new shape of an image-like array after resizing.

Parameters
----------
from_shape : tuple or ndarray
    Old shape of the array. Usually expected to be a tuple of form ``(H, W)`` or ``(H, W, C)`` or
    alternatively an array with two or three dimensions.

to_shape : None or tuple of ints or tuple of floats or int or float or ndarray
    New shape of the array.

        * If None, then `from_shape` will be used as the new shape.
        * If an int ``V``, then the new shape will be ``(V, V, [C])``, where ``C`` will be added if it
          is part of `from_shape`.
        * If a float ``V``, then the new shape will be ``(H*V, W*V, [C])``, where ``H`` and ``W`` are the old
          height/width.
        * If a tuple ``(H', W', [C'])`` of ints, then ``H'`` and ``W'`` will be used as the new height
          and width.
        * If a tuple ``(H', W', [C'])`` of floats (except ``C``), then ``H'`` and ``W'`` will
          be used as the new height and width.
        * If a numpy array, then the array's shape will be used.

Returns
-------
to_shape_computed : tuple of int
    New shape.