示例#1
0
    def getComicPage(self, comic_id, page_number, max_height=None):
        (path, page_count) = self.getSession().query(Comic.path, Comic.page_count) \
                                 .filter(Comic.id == int(comic_id)).first()

        image_data = None
        default_img_file = AppFolders.imagePath("default.jpg")

        if path is not None:
            if int(page_number) < page_count:
                ca = self.getComicArchive(path)
                image_data = ca.getPage(int(page_number))

        if image_data is None:
            with open(default_img_file, 'rb') as fd:
                image_data = fd.read()
            return image_data

        # resize image
        if max_height is not None:
            try:
                image_data = utils.resizeImage(int(max_height), image_data)
            except Exception as e:
                #logging.error(e)
                pass
        return image_data
示例#2
0
    def getComicPage(self, comic_id, page_number, max_height = None):
        (path, page_count) = self.getSession().query(Comic.path, Comic.page_count) \
                                 .filter(Comic.id == int(comic_id)).first()

        image_data = None
        default_img_file = AppFolders.imagePath("default.jpg")

        if path is not None:
            if int(page_number) < page_count:
                ca = self.getComicArchive(path)
                image_data = ca.getPage(int(page_number))

        if image_data is None:
            with open(default_img_file, 'rb') as fd:
                image_data = fd.read()
            return image_data

        # resize image
        if max_height is not None:
            try:
                image_data = utils.resizeImage(int(max_height), image_data)
            except Exception as e:
                #logging.error(e)
                pass
        return image_data
示例#3
0
 def getComicArchive(self, path):
     # should also look at modified time of file
     for ca in self.comicArchiveList:
         if ca.path == path:
             # remove from list and put at end
             self.comicArchiveList.remove(ca)
             self.comicArchiveList.append(ca)
             return ca
     else:
         ca = ComicArchive(path, default_image_path=AppFolders.imagePath("default.jpg"))
         self.comicArchiveList.append(ca)
         if len(self.comicArchiveList) > 10:
             self.comicArchiveList.pop(0)
         return ca
示例#4
0
 def getComicArchive(self, path):
     # should also look at modified time of file
     for ca in self.comicArchiveList:
         if ca.path == path:
             # remove from list and put at end
             self.comicArchiveList.remove(ca)
             self.comicArchiveList.append(ca)
             return ca
     else:
         ca = ComicArchive(path, default_image_path=AppFolders.imagePath("default.jpg"))
         self.comicArchiveList.append(ca)
         if len(self.comicArchiveList) > 10:
             self.comicArchiveList.pop(0)
         return ca