mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Rasterize SVG covers to full profile size
This commit is contained in:
parent
f2b914e6d8
commit
3cc29da208
@ -52,6 +52,9 @@ class SVGRasterizer(object):
|
|||||||
size.setHeight(box[3] - box[1])
|
size.setHeight(box[3] - box[1])
|
||||||
if width or height:
|
if width or height:
|
||||||
size.scale(width, height, Qt.KeepAspectRatio)
|
size.scale(width, height, Qt.KeepAspectRatio)
|
||||||
|
logger = self.oeb.logger
|
||||||
|
logger.info('Rasterizing %r to %dx%d'
|
||||||
|
% (elem, size.width(), size.height()))
|
||||||
image = QImage(size, QImage.Format_ARGB32_Premultiplied)
|
image = QImage(size, QImage.Format_ARGB32_Premultiplied)
|
||||||
image.fill(QColor("white").rgb())
|
image.fill(QColor("white").rgb())
|
||||||
painter = QPainter(image)
|
painter = QPainter(image)
|
||||||
@ -180,9 +183,9 @@ class SVGRasterizer(object):
|
|||||||
cover = self.oeb.manifest.ids[str(covers[0])]
|
cover = self.oeb.manifest.ids[str(covers[0])]
|
||||||
if not cover.media_type == SVG_MIME:
|
if not cover.media_type == SVG_MIME:
|
||||||
return
|
return
|
||||||
logger = self.oeb.logger
|
width = (self.profile.width / 72) * self.profile.dpi
|
||||||
logger.info('Rasterizing %r to %dx%d' % (cover.href, 600, 800))
|
height = (self.profile.height / 72) * self.profile.dpi
|
||||||
data = self.rasterize_svg(cover.data, 600, 800)
|
data = self.rasterize_svg(cover.data, width, height)
|
||||||
href = os.path.splitext(cover.href)[0] + '.png'
|
href = os.path.splitext(cover.href)[0] + '.png'
|
||||||
id, href = self.oeb.manifest.generate(cover.id, href)
|
id, href = self.oeb.manifest.generate(cover.id, href)
|
||||||
self.oeb.manifest.add(id, href, PNG_MIME, data=data)
|
self.oeb.manifest.add(id, href, PNG_MIME, data=data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user