def process_resize_value(resize_spec):
  """Helper method to process input resize spec.

  Args:
    resize_spec: Either None, a python scalar, or a sequence with length <=2.
      Each value in the sequence should be a python integer.

  Returns:
    None if input size is not valid, or 2-tuple of (height, width), derived
      from input resize_spec.
  """
  if not resize_spec:
    return None

  if isinstance(resize_spec, int):
    # For conveniences and also backward compatibility.
    resize_spec = (resize_spec,)

  resize_spec = tuple(resize_spec)

  if len(resize_spec) == 1:
    resize_spec = (resize_spec[0], resize_spec[0])

  if len(resize_spec) != 2:
    raise ValueError('Unable to process input resize_spec: %s' % resize_spec)

  if resize_spec[0] <= 0 or resize_spec[1] <= 0:
    return None

  return resize_spec