def convert_to_inches(s):
    """
    Convert an SVG unit string like '42.5mm' or '12in' to inches as a float. If
    the unit string does not include physical units, return None.
    """
    assert s
    s = s.strip()
    for unit in ('in', 'mm', 'cm', 'px', 'pt'):
        if s[-2:] == unit:
            v = s[:-2]
            break
    else:
        return None
    v = float(v)
    if unit == 'in':
        return v
    elif unit == 'mm':
        return v / 25.4
    elif unit == 'cm':
        return v / 2.54
    elif unit == 'px':
        return v / 96.0
    elif unit == 'pt':
        return v / 72.0
