'Return the cover image or None. By default, returns the cover as a
bytestring.
WARNING: Using as_path will copy the cover to a temp file and return
the path to the temp file. You should delete the temp file when you are
done with it.
:param as_file: If True return the image as an open file object (a SpooledTemporaryFile)
:param as_image: If True return the image as a QImage object
:param as_path: If True return the image as a path pointing to a
temporary file'

@api
def cover(self, book_id, as_file=False, as_image=False, as_path=False):

    if as_file:
        ret = SpooledTemporaryFile(SPOOL_SIZE)
        if (not self.copy_cover_to(book_id, ret)):
            return
        ret.seek(0)
    elif as_path:
        pt = PersistentTemporaryFile(u'_dbcover.jpg')
        with pt:
            if (not self.copy_cover_to(book_id, pt)):
                return
        ret = pt.name
    else:
        buf = BytesIO()
        if (not self.copy_cover_to(book_id, buf)):
            return
        ret = buf.getvalue()
        if as_image:
            from PyQt5.Qt import QImage
            i = QImage()
            i.loadFromData(ret)
            ret = i
    return ret
