Fix #5020 (Mobi -> ePub omits some image files)

This commit is contained in:
Kovid Goyal 2010-02-28 12:32:37 -07:00
parent da8bfe6b02
commit 590dc5b2de

View File

@ -4,13 +4,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
Read data from .mobi files Read data from .mobi files
''' '''
import functools import functools, shutil, os, re, struct, textwrap, cStringIO, sys
import os
import re
import struct
import textwrap
import cStringIO
import sys
try: try:
from PIL import Image as PILImage from PIL import Image as PILImage
@ -620,6 +614,16 @@ class MobiReader(object):
* opf.cover.split('/'))): * opf.cover.split('/'))):
opf.cover = None opf.cover = None
cover = opf.cover
if cover is not None:
cover = cover.replace('/', os.sep)
if os.path.exists(cover):
ncover = 'images'+os.sep+'calibre_cover.jpg'
if os.path.exists(ncover):
os.remove(ncover)
shutil.copyfile(cover, ncover)
opf.cover = ncover.replace(os.sep, '/')
manifest = [(htmlfile, 'application/xhtml+xml'), manifest = [(htmlfile, 'application/xhtml+xml'),
(os.path.abspath('styles.css'), 'text/css')] (os.path.abspath('styles.css'), 'text/css')]
bp = os.path.dirname(htmlfile) bp = os.path.dirname(htmlfile)