def query_image(ref): ''' This method takes either an IssueRef object, a SeriesRef object, or a direct URL string, and queries the database for a single associated cover image. If no image can be found, if an error occurs, or if the given ref is None, this method will return None. Note that the returned Image object (if there is one) is a .NET Image object, which must be explicitly Disposed() when you are done with it, in order to prevent memory leaks. ''' return utils.strip_back_cover( cvdb._query_image(ref) )
def __get_local_hash(book): ''' Gets the image hash for the cover of the give ComicBook object. Returns None if the cover image was empty or couldn't be hashed for any reason. ''' hash = None # matches nothing try: image = book.create_image_of_page(0) if book else None if image: image = utils.strip_back_cover(image) hash = imagehash.hash(image) finally: if "image" in locals() and image: image.Dispose() return hash
def __get_local_hash(book): ''' Gets the image hash for the cover of the give ComicBook object. Returns None if the cover image was empty or couldn't be hashed for any reason. ''' hash = None # matches nothing try: image = book.create_image_of_page(0) if book else None; if image: image = utils.strip_back_cover(image) hash = imagehash.hash(image) finally: if "image" in locals() and image: image.Dispose() return hash
def __get_remote_hash(ref): ''' Gets the image hash for a remote comic book resource. This resource can be a SeriesRef (hashes series art), an IssueRef (hashes the first issue cover) or a URL to an image on the web. Returns None if the ref led to an image that was empty or couldn't be hashed for any reason. ''' hash = None # matches nothing try: image = db.query_image(ref) if ref else None if image: image = utils.strip_back_cover(image) hash = imagehash.hash(image) finally: if "image" in locals() and image: image.Dispose() return hash
def create_image_of_page(self, page_index): ''' Overridden to implement the superclass method of the same name. ''' fileless = not self.path_s page_image = None if fileless: page_image = None else: try: page_image = self.__scraper.comicrack.App.GetComicPage( self.__crbook, page_index) except Exception: # we can't rely on self.page_count_n, thanks to bug 235. # (page count is zero after "clear data", so use try-catch instead. page_image = None if page_image: page_image = utils.strip_back_cover(page_image) return page_image