mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 11:14:02 +02:00
Fix #7003 (Error when converting HTML/ZIP to RTF)
This commit is contained in:
parent
67722fca23
commit
a22dbab0c0
1 changed files with 4 additions and 12 deletions
|
|
@ -10,13 +10,6 @@
|
|||
|
||||
import os
|
||||
import re
|
||||
|
||||
try:
|
||||
from PIL import Image
|
||||
Image
|
||||
except ImportError:
|
||||
import Image
|
||||
|
||||
import cStringIO
|
||||
|
||||
from lxml import etree
|
||||
|
|
@ -26,6 +19,7 @@
|
|||
from calibre.ebooks.oeb.stylizer import Stylizer
|
||||
from calibre.ebooks.metadata import authors_to_string
|
||||
from calibre.utils.filenames import ascii_text
|
||||
from calibre.utils.magick.draw import save_cover_data_to, identify_data
|
||||
|
||||
TAGS = {
|
||||
'b': '\\b',
|
||||
|
|
@ -153,10 +147,8 @@ def insert_images(self, text):
|
|||
return text
|
||||
|
||||
def image_to_hexstring(self, data):
|
||||
im = Image.open(cStringIO.StringIO(data))
|
||||
data = cStringIO.StringIO()
|
||||
im.convert('RGB').save(data, 'JPEG')
|
||||
data = data.getvalue()
|
||||
data = save_cover_data_to(data, 'cover.jpg', return_data=True)
|
||||
width, height = identify_data(data)[:2]
|
||||
|
||||
raw_hex = ''
|
||||
for char in data:
|
||||
|
|
@ -173,7 +165,7 @@ def image_to_hexstring(self, data):
|
|||
col += 1
|
||||
hex_string += char
|
||||
|
||||
return (hex_string, im.size[0], im.size[1])
|
||||
return (hex_string, width, height)
|
||||
|
||||
def clean_text(self, text):
|
||||
# Remove excess spaces at beginning and end of lines
|
||||
|
|
|
|||
Loading…
Reference in a new issue