human
Complete this python program:
def findImageFile(filename):
assistant
#Here is the Python program you requested.

    """Tests whether the filename is an image file. If not will try some common
    alternatives (e.g. extensions .jpg .tif...)
    """
    isfile = os.path.isfile
    if isfile(filename):
        return filename
    orig = copy.copy(filename)
    extensions = ('.jpg', '.png', '.tif', '.bmp', '.gif', '.jpeg', '.tiff')
    def logCorrected(orig, actual):
        logging.warn('Requested    image    {!r}    not    found    but    similar    filename    {!r}    exists.    This    will    be    used    instead    but    changing    the    filename    is    advised.'.format(orig, actual))
    if filename.endswith(extensions):
        filename = os.path.splitext(orig)[0]
    if isfile(filename):
        logCorrected(orig, filename)
        return filename
    for ext in extensions:
        if isfile((filename + ext)):
            filename += ext
            logCorrected(orig, filename)
            return filename