예제 #1
0
파일: input.py 프로젝트: MarioJC/calibre
 def render(self):
     from calibre.utils.img import image_from_data, scale_image, crop_image
     with lopen(self.path_to_page, 'rb') as f:
         img = image_from_data(f.read())
     width, height = img.width(), img.height()
     if self.num == 0:  # First image so create a thumbnail from it
         with lopen(os.path.join(self.dest, 'thumbnail.png'), 'wb') as f:
             f.write(scale_image(img, as_png=True)[-1])
     self.pages = [img]
     if width > height:
         if self.opts.landscape:
             self.rotate = True
         else:
             half = int(width/2)
             split1 = crop_image(img, 0, 0, half, height)
             split2 = crop_image(img, half, 0, width - half, height)
             self.pages = [split2, split1] if self.opts.right2left else [split1, split2]
     self.process_pages()
예제 #2
0
 def render(self):
     from calibre.utils.img import image_from_data, scale_image, crop_image
     with lopen(self.path_to_page, 'rb') as f:
         img = image_from_data(f.read())
     width, height = img.width(), img.height()
     if self.num == 0:  # First image so create a thumbnail from it
         with lopen(os.path.join(self.dest, 'thumbnail.png'), 'wb') as f:
             f.write(scale_image(img, as_png=True)[-1])
     self.pages = [img]
     if width > height:
         if self.opts.landscape:
             self.rotate = True
         else:
             half = width // 2
             split1 = crop_image(img, 0, 0, half, height)
             split2 = crop_image(img, half, 0, width - half, height)
             self.pages = [split2, split1
                           ] if self.opts.right2left else [split1, split2]
     self.process_pages()