mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Viewer: Treat the first image in comics as the cover
This commit is contained in:
parent
7a9e791506
commit
b20f1d3fd7
@ -204,10 +204,13 @@ class ComicInput(InputFormatPlugin):
|
||||
return os.path.basename(x)
|
||||
return '/'.join(x.split(os.sep)[-2:])
|
||||
|
||||
cover_href = None
|
||||
for comic in comics:
|
||||
pages, wrappers = comic[1:]
|
||||
entries += [(w, None) for w in map(href, wrappers)] + \
|
||||
[(x, None) for x in map(href, pages)]
|
||||
page_entries = [(x, None) for x in map(href, pages)]
|
||||
entries += [(w, None) for w in map(href, wrappers)] + page_entries
|
||||
if cover_href is None and page_entries:
|
||||
cover_href = page_entries[0][0]
|
||||
opf.create_manifest(entries)
|
||||
spine = []
|
||||
for comic in comics:
|
||||
@ -216,6 +219,8 @@ class ComicInput(InputFormatPlugin):
|
||||
for comic in comics:
|
||||
self._images.extend(comic[1])
|
||||
opf.create_spine(spine)
|
||||
if self.for_viewer and cover_href:
|
||||
opf.guide.set_cover(cover_href)
|
||||
toc = TOC()
|
||||
if len(comics) == 1:
|
||||
wrappers = comics[0][2]
|
||||
|
@ -17,6 +17,7 @@ from css_parser import replaceUrls
|
||||
from css_parser.css import CSSRule
|
||||
|
||||
from calibre import force_unicode, prepare_string_for_xml
|
||||
from calibre.customize.ui import plugin_for_input_format
|
||||
from calibre.ebooks import parse_css_length
|
||||
from calibre.ebooks.css_transform_rules import StyleDeclaration
|
||||
from calibre.ebooks.oeb.base import (
|
||||
@ -335,6 +336,9 @@ class Container(ContainerBase):
|
||||
raster_cover_name = self.href_to_name(item.get('href'), self.opf_name)
|
||||
with self.open(raster_cover_name, 'wb') as dest:
|
||||
dest.write(generic_cover())
|
||||
input_plugin = plugin_for_input_format(input_fmt)
|
||||
if getattr(input_plugin, 'is_image_collection', False):
|
||||
return raster_cover_name, None
|
||||
item = self.generate_item(name='titlepage.html', id_prefix='titlepage')
|
||||
titlepage_name = self.href_to_name(item.get('href'), self.opf_name)
|
||||
raw = templ % prepare_string_for_xml(self.name_to_href(raster_cover_name, titlepage_name), True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user