Fix a regression in 3.45.0 caused by py3 porting that broke rasterization of SVG images when converting to formats such as MOBI that do not support SVG. Fixes #1836463 [Private bug](https://bugs.launchpad.net/calibre/+bug/1836463)

This commit is contained in:
Kovid Goyal 2019-07-15 09:21:22 +05:30
parent bae5d86600
commit c1e6aca8e0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -121,10 +121,10 @@ class SVGRasterizer(object):
if abshref not in hrefs:
continue
linkee = hrefs[abshref]
data = unicode_type(linkee)
data = linkee.bytes_representation
ext = what(None, data) or 'jpg'
with PersistentTemporaryFile(suffix='.'+ext) as pt:
pt.write(data.encode('utf-8'))
pt.write(data)
self.temp_files.append(pt.name)
elem.attrib[XLINK('href')] = pt.name
return svg
@ -182,7 +182,7 @@ class SVGRasterizer(object):
height = style['height']
width = (width / 72) * self.profile.dpi
height = (height / 72) * self.profile.dpi
data = QByteArray(unicode_type(svgitem).encode('utf-8'))
data = QByteArray(svgitem.bytes_representation)
svg = QSvgRenderer(data)
size = svg.defaultSize()
size.scale(width, height, Qt.KeepAspectRatio)