mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Conversion: When converting SVG images for formats that do not support SVG and the SVG has an invalid viewBox, ignore the viewBox instead of aborting conversion
This commit is contained in:
parent
dd54ccc0d0
commit
46383bf264
@ -6,7 +6,7 @@ from __future__ import with_statement
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
|
||||
|
||||
import os
|
||||
import os, re
|
||||
from urlparse import urldefrag
|
||||
from lxml import etree
|
||||
from PyQt4.QtCore import Qt
|
||||
@ -68,8 +68,12 @@ class SVGRasterizer(object):
|
||||
logger = self.oeb.logger
|
||||
|
||||
if view_box is not None:
|
||||
box = [float(x) for x in view_box.split()]
|
||||
try:
|
||||
box = [float(x) for x in filter(None, re.split('[, ]', view_box))]
|
||||
sizes = [box[2]-box[0], box[3] - box[1]]
|
||||
except (TypeError, ValueError, IndexError):
|
||||
logger.warn('SVG image has invalid viewBox="%s", ignoring the viewBox' % view_box)
|
||||
else:
|
||||
for image in elem.xpath('descendant::*[local-name()="image" and '
|
||||
'@height and contains(@height, "%")]'):
|
||||
logger.info('Found SVG image height in %, trying to convert...')
|
||||
|
Loading…
x
Reference in New Issue
Block a user