diff --git a/src/libprs500/lrf/html/convert_from.py b/src/libprs500/lrf/html/convert_from.py
index 64fc91abfd..a130727407 100644
--- a/src/libprs500/lrf/html/convert_from.py
+++ b/src/libprs500/lrf/html/convert_from.py
@@ -326,7 +326,7 @@ class HTMLConverter(object):
self.current_block = TextBlock()
self.current_para = Paragraph()
if self.cover:
- self.add_image_block(self.cover)
+ self.add_image_page(self.cover)
self.top = self.current_block
self.process_children(self.soup, {})
@@ -422,13 +422,13 @@ class HTMLConverter(object):
self.current_page = Page()
- def add_image_block(self, path):
+ def add_image_page(self, path):
if os.access(path, os.R_OK):
self.end_page()
page = ImagePage()
if not self.images.has_key(path):
self.images[path] = ImageStream(path)
- page.append(ImageBlock(self.images[path], blockStyle=BlockStyle(blockrule='block-fixed')))
+ page.append(ImageBlock(self.images[path]))
self.book.append(page)
def process_children(self, ptag, pcss):
@@ -504,14 +504,43 @@ class HTMLConverter(object):
path = purl[2]
if path and os.path.splitext(path)[1][1:].lower() in \
['png', 'jpg', 'bmp', 'jpeg']:
- self.add_image_block(path)
+ self.add_image_page(path)
else:
span = _Span()
self.current_para.append(span)
self.links.append(HTMLConverter.Link(span, tag))
elif tagname == 'img':
- if tag.has_key('src'):
- self.add_image_block(tag['src'])
+ if tag.has_key('src') and os.access(tag['src'], os.R_OK):
+ width, height = 600, 800
+ try:
+ try:
+ from PIL import Image
+ except:
+ pass
+ else:
+ im = Image.open(tag['src'])
+ width, height = im.size
+ if tag.has_key('width'):
+ width = int(tag['width'])
+ if tag.has_key('height'):
+ height = int(tag['height'])
+ except:
+ pass
+ self.current_block.append(self.current_para)
+ self.current_page.append(self.current_block)
+ self.current_para = Paragraph()
+ self.current_block = TextBlock()
+ path = os.path.abspath(tag['src'])
+ print width, height
+ if not self.images.has_key(path):
+ self.images[path] = ImageStream(path)
+ im = ImageBlock(self.images[path], x1=width, y1=height,
+ xsize=width, ysize=height)
+ self.current_page.append(im)
+ else:
+ print >>sys.stderr, "Failed to process", tag
+
+ self.add_image_page(tag['src'])
elif tagname in ['style', 'link']:
if tagname == 'style':
for c in tag.contents:
diff --git a/src/libprs500/lrf/pylrs/pylrs.py b/src/libprs500/lrf/pylrs/pylrs.py
index 9d173d117f..e324b9787f 100644
--- a/src/libprs500/lrf/pylrs/pylrs.py
+++ b/src/libprs500/lrf/pylrs/pylrs.py
@@ -1446,7 +1446,7 @@ class Paragraph(LrsContainer):
explicit .append methods to build up the text stream.
"""
def __init__(self, text=None):
- LrsContainer.__init__(self, [Text, CR, DrawChar, CharButton,
+ LrsContainer.__init__(self, [Text, CR, DrawChar, CharButton, Span,
LrsSimpleChar1, basestring])
if text is not None:
self.append(text)
@@ -2137,7 +2137,8 @@ class ImageBlock(LrsObject, LrsContainer, LrsAttributes):
defaults = dict(blockwidth="600", blockheight="800")
def __init__(self, refstream, x0="0", y0="0", x1="600", y1="800",
- xsize="600", ysize="800", blockStyle=None,
+ xsize="600", ysize="800",
+ blockStyle=BlockStyle(blockrule='block-fixed'),
alttext=None, **settings):
LrsObject.__init__(self)
LrsContainer.__init__(self, [])