def _val(var, is_percent=False):
    """
    Tries to determine the appropriate value of a particular variable that is
    passed in. If the value is supposed to be a percentage, a whole integer
    will be sought after and then turned into a floating point number between
    0 and 1. If the value is supposed to be an integer, the variable is cast
    into an integer.
    """
    try:
        if is_percent:
            var = float(int(var.strip('%')) / 100.0)
        else:
            var = int(var)
    except ValueError:
        raise ValueError('invalid watermark parameter: ' + var)
    return var
