def check_resize(resize):
    """checks resize parameter if illegal value raises exception"""
    if resize is None:
        return

    resize = resize.lower().strip()

    if 'x' in resize:
        tmp = resize.lower().split('x')
        tmp = [x.strip() for x in resize.split('x')]
        if len(tmp) == 2 and tmp[0].isdigit() and tmp[1].isdigit():
            return
    elif '%' in resize:
        tmp = resize.split('%')[0]
        if tmp.isnumeric():
            tmp = int(tmp)
            if 1 <= tmp <= 1000:
                return
            else:
                raise PercentageOutOfRange("percentage must be between 1 and 1000")

    raise MallformedResize('Resize value "%s" is mallformed. '
                           'Desired format is: {width}x{height} or {percentage}%%' % resize)
checks resize parameter if illegal value raises exception