mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
RTF Output: Ignore corrupted images in the input document, instead of erroring out. Fixes #959600 (Corrupt png prevents conversion)
This commit is contained in:
parent
bfff783d1e
commit
f551cde996
@ -161,8 +161,14 @@ class RTFMLizer(object):
|
|||||||
for item in self.oeb_book.manifest:
|
for item in self.oeb_book.manifest:
|
||||||
if item.media_type in OEB_RASTER_IMAGES:
|
if item.media_type in OEB_RASTER_IMAGES:
|
||||||
src = os.path.basename(item.href)
|
src = os.path.basename(item.href)
|
||||||
|
try:
|
||||||
data, width, height = self.image_to_hexstring(item.data)
|
data, width, height = self.image_to_hexstring(item.data)
|
||||||
text = text.replace('SPECIAL_IMAGE-%s-REPLACE_ME' % src, '\n\n{\\*\\shppict{\\pict\\picw%i\\pich%i\\jpegblip \n%s\n}}\n\n' % (width, height, data))
|
except:
|
||||||
|
self.log.warn('Image %s is corrupted, ignoring'%item.href)
|
||||||
|
repl = '\n\n'
|
||||||
|
else:
|
||||||
|
repl = '\n\n{\\*\\shppict{\\pict\\picw%i\\pich%i\\jpegblip \n%s\n}}\n\n' % (width, height, data)
|
||||||
|
text = text.replace('SPECIAL_IMAGE-%s-REPLACE_ME' % src, repl)
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def image_to_hexstring(self, data):
|
def image_to_hexstring(self, data):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user