summaryrefslogtreecommitdiff
path: root/bin/report/render/html2html/html2html.py
diff options
context:
space:
mode:
authorFabien Pinckaers <fp@tinyerp.com>2009-05-25 16:57:04 +0200
committerFabien Pinckaers <fp@tinyerp.com>2009-05-25 16:57:04 +0200
commitcc920a782a193415776f1a30b8d87003c5251337 (patch)
treecf538cbfd1a1aa6528f2a62ce71cd329afcb5988 /bin/report/render/html2html/html2html.py
parente9f4db614a8354ccd871ce36a6095d3841ecd067 (diff)
parent3837623fa2000e350e755f697fb3b73012dbe679 (diff)
merge
bzr revid: fp@tinyerp.com-20090525145704-5vdrw64fdr3uzsvz
Diffstat (limited to 'bin/report/render/html2html/html2html.py')
-rw-r--r--bin/report/render/html2html/html2html.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/bin/report/render/html2html/html2html.py b/bin/report/render/html2html/html2html.py
index 7894dd78516..fb1f6fcedd0 100644
--- a/bin/report/render/html2html/html2html.py
+++ b/bin/report/render/html2html/html2html.py
@@ -24,7 +24,12 @@ from report.render.rml2pdf import utils
from lxml import etree
import copy
import pooler
+import base64
+import cStringIO
+import re
+from reportlab.lib.utils import ImageReader
+_regex = re.compile('\[\[(.+?)\]\]')
class html2html(object):
def __init__(self, html, localcontext):
@@ -46,9 +51,17 @@ class html2html(object):
process_text(child, new_child)
else:
if new_child.tag=='img' and new_child.get('name'):
- src = utils._process_text(self, new_child.get('name'))
- if src :
- new_child.set('src','data:image/gif;base64,%s'%src)
+ if _regex.findall(new_child.get('name')) :
+ src = utils._process_text(self, new_child.get('name'))
+ if src :
+ new_child.set('src','data:image/gif;base64,%s'%src)
+ output = cStringIO.StringIO(base64.decodestring(src))
+ img = ImageReader(output)
+ (width,height) = img.getSize()
+ new_child.set('width',str(width))
+ new_child.set('height',str(height))
+ else :
+ new_child.getparent().remove(new_child)
new_child.text = utils._process_text(self, child.text)
self._node = copy.deepcopy(self.etree)
for n in self._node: