From c1e6aca8e06d8e05ea1f5fe05043e070897b6583 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 15 Jul 2019 09:21:22 +0530 Subject: [PATCH] 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) --- src/calibre/ebooks/oeb/transforms/rasterize.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/oeb/transforms/rasterize.py b/src/calibre/ebooks/oeb/transforms/rasterize.py index cfa320e85f..0a58dc6695 100644 --- a/src/calibre/ebooks/oeb/transforms/rasterize.py +++ b/src/calibre/ebooks/oeb/transforms/rasterize.py @@ -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)