return True if the name or path is endswith {jpg|png|gif|jpeg}

def is_image(name, exts=None):
    """return True if the name or path is endswith {jpg|png|gif|jpeg}"""

    default = ['jpg', 'png', 'gif', 'jpeg']
    if exts:
        default += exts

    flag = False
    for ext in default:
        if name.lower().endswith(ext):
            flag = True
            break
    return flag