mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1150 (any2epub crashes converting lit file) and add new epub icon
This commit is contained in:
parent
c42451980b
commit
35d7034d52
@ -142,7 +142,7 @@ def resize_cover(im, opts):
|
|||||||
if delta > 0:
|
if delta > 0:
|
||||||
nwidth = int(width + delta*(width))
|
nwidth = int(width + delta*(width))
|
||||||
nheight = int(height + delta*(height))
|
nheight = int(height + delta*(height))
|
||||||
im = im.resize((int(nwidth), int(nheight)), PILImage.ANTIALIAS).convert('RGB')
|
im = im.resize((int(nwidth), int(nheight)), PILImage.ANTIALIAS)
|
||||||
return im
|
return im
|
||||||
|
|
||||||
def process_title_page(mi, filelist, htmlfilemap, opts, tdir):
|
def process_title_page(mi, filelist, htmlfilemap, opts, tdir):
|
||||||
@ -156,12 +156,17 @@ def process_title_page(mi, filelist, htmlfilemap, opts, tdir):
|
|||||||
metadata_cover = mi.cover
|
metadata_cover = mi.cover
|
||||||
if metadata_cover and not os.path.exists(metadata_cover):
|
if metadata_cover and not os.path.exists(metadata_cover):
|
||||||
metadata_cover = None
|
metadata_cover = None
|
||||||
|
|
||||||
|
cpath = '/'.join(('resources', '_cover_.jpg'))
|
||||||
|
cover_dest = os.path.join(tdir, 'content', *cpath.split('/'))
|
||||||
|
with open(cover_dest, 'wb') as f_cover_dest:
|
||||||
if metadata_cover is not None:
|
if metadata_cover is not None:
|
||||||
with open(metadata_cover, 'rb') as src:
|
with open(metadata_cover, 'rb') as src:
|
||||||
try:
|
try:
|
||||||
im = PILImage.open(src)
|
im = PILImage.open(src).convert('RGB')
|
||||||
if opts.profile.screen_size is not None:
|
if opts.profile.screen_size is not None:
|
||||||
im = resize_cover(im, opts)
|
im = resize_cover(im, opts)
|
||||||
|
im.save(f_cover_dest, format='jpeg')
|
||||||
metadata_cover = im
|
metadata_cover = im
|
||||||
except:
|
except:
|
||||||
metadata_cover = None
|
metadata_cover = None
|
||||||
@ -172,19 +177,17 @@ def process_title_page(mi, filelist, htmlfilemap, opts, tdir):
|
|||||||
if specified_cover is not None:
|
if specified_cover is not None:
|
||||||
with open(specified_cover, 'rb') as src:
|
with open(specified_cover, 'rb') as src:
|
||||||
try:
|
try:
|
||||||
im = PILImage.open(src)
|
im = PILImage.open(src).convert('RGB')
|
||||||
if opts.profile.screen_size is not None:
|
if opts.profile.screen_size is not None:
|
||||||
im = resize_cover(im, opts)
|
im = resize_cover(im, opts)
|
||||||
specified_cover = im
|
specified_cover = im
|
||||||
|
im.save(f_cover_dest, format='jpeg')
|
||||||
except:
|
except:
|
||||||
specified_cover = None
|
specified_cover = None
|
||||||
|
|
||||||
cover = metadata_cover if specified_cover is None or (opts.prefer_metadata_cover and metadata_cover is not None) else specified_cover
|
cover = metadata_cover if specified_cover is None or (opts.prefer_metadata_cover and metadata_cover is not None) else specified_cover
|
||||||
|
|
||||||
if hasattr(cover, 'save'):
|
if hasattr(cover, 'save'):
|
||||||
cpath = '/'.join(('resources', '_cover_.jpg'))
|
|
||||||
cover_dest = os.path.join(tdir, 'content', *cpath.split('/'))
|
|
||||||
with open(cover_dest, 'wb') as f:
|
|
||||||
im.save(f, format='jpeg')
|
|
||||||
titlepage = '''\
|
titlepage = '''\
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||||
<head>
|
<head>
|
||||||
@ -203,7 +206,8 @@ def process_title_page(mi, filelist, htmlfilemap, opts, tdir):
|
|||||||
with open(tppath, 'wb') as f:
|
with open(tppath, 'wb') as f:
|
||||||
f.write(titlepage)
|
f.write(titlepage)
|
||||||
return tp if old_title_page is None else None, True
|
return tp if old_title_page is None else None, True
|
||||||
|
elif os.path.exists(cover_dest):
|
||||||
|
os.remove(cover_dest)
|
||||||
return None, old_title_page is not None
|
return None, old_title_page is not None
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 274 KiB |
@ -399,7 +399,7 @@ def install_man_pages(fatal_errors):
|
|||||||
prog = src[:src.index('=')].strip()
|
prog = src[:src.index('=')].strip()
|
||||||
if prog in ('prs500', 'pdf-meta', 'epub-meta', 'lit-meta',
|
if prog in ('prs500', 'pdf-meta', 'epub-meta', 'lit-meta',
|
||||||
'markdown-calibre', 'calibre-debug', 'fb2-meta',
|
'markdown-calibre', 'calibre-debug', 'fb2-meta',
|
||||||
'calibre-fontconfig', 'calibre-parallel',
|
'calibre-fontconfig', 'calibre-parallel', 'odt-meta',
|
||||||
'rb-meta', 'imp-meta'):
|
'rb-meta', 'imp-meta'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user