Get image file.

def getimage(app):
    """Get image file."""
    # append source directory to TEMPLATE_PATH so template is found
    srcdir = os.path.abspath(os.path.dirname(__file__))
    TEMPLATE_PATH.append(srcdir)
    staticbase = '_static'
    buildpath = os.path.join(app.outdir, staticbase)
    try:
        os.makedirs(buildpath)
    except OSError:
        if not os.path.isdir(buildpath):
            raise

    if app.config.sphinxmark_image == 'default':
        imagefile = 'watermark-draft.png'
        imagepath = os.path.join(srcdir, imagefile)
        copy(imagepath, buildpath)
        LOG.debug('[sphinxmark] Using default image: ' + imagefile)
    elif app.config.sphinxmark_image == 'text':
        imagefile = createimage(app, srcdir, buildpath)
        LOG.debug('[sphinxmark] Image: ' + imagefile)
    else:
        imagefile = app.config.sphinxmark_image

        if app.config.html_static_path:
            staticpath = app.config.html_static_path[0]
        else:
            staticpath = '_static'

        LOG.debug('[sphinxmark] static path: ' + staticpath)
        imagepath = os.path.join(app.confdir, staticpath, imagefile)
        LOG.debug('[sphinxmark] Imagepath: ' + imagepath)

        try:
            copy(imagepath, buildpath)
        except Exception:
            message = ("Cannot find '%s'. Put watermark images in the "
                       "'_static' directory or specify the location using "
                       "'html_static_path'." % imagefile)
            LOG.warning(message)
            LOG.warning('Failed to add watermark.')
            return

    return(buildpath, imagefile)