mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
FB2 Output: Speed up image data splitting
This commit is contained in:
parent
db583073de
commit
2ce345e5dd
@ -19,7 +19,7 @@ from calibre.constants import __appname__, __version__
|
|||||||
from calibre.utils.localization import lang_as_iso639_1
|
from calibre.utils.localization import lang_as_iso639_1
|
||||||
from calibre.utils.img import save_cover_data_to
|
from calibre.utils.img import save_cover_data_to
|
||||||
from calibre.ebooks.oeb.base import urlnormalize
|
from calibre.ebooks.oeb.base import urlnormalize
|
||||||
from polyglot.builtins import unicode_type, string_or_bytes
|
from polyglot.builtins import unicode_type, string_or_bytes, range
|
||||||
from polyglot.binary import as_base64_unicode
|
from polyglot.binary import as_base64_unicode
|
||||||
|
|
||||||
|
|
||||||
@ -315,14 +315,8 @@ class FB2MLizer(object):
|
|||||||
raw_data = as_base64_unicode(item.data)
|
raw_data = as_base64_unicode(item.data)
|
||||||
content_type = item.media_type
|
content_type = item.media_type
|
||||||
# Don't put the encoded image on a single line.
|
# Don't put the encoded image on a single line.
|
||||||
data = ''
|
step = 72
|
||||||
col = 1
|
data = '\n'.join(raw_data[i:i+step] for i in range(0, len(raw_data), step))
|
||||||
for char in raw_data:
|
|
||||||
if col == 72:
|
|
||||||
data += '\n'
|
|
||||||
col = 1
|
|
||||||
col += 1
|
|
||||||
data += char
|
|
||||||
images.append('<binary id="%s" content-type="%s">%s\n</binary>' % (self.image_hrefs[item.href], content_type, data))
|
images.append('<binary id="%s" content-type="%s">%s\n</binary>' % (self.image_hrefs[item.href], content_type, data))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.error('Error: Could not include file %s because '
|
self.log.error('Error: Could not include file %s because '
|
||||||
|
Loading…
x
Reference in New Issue
Block a user