Skip to content

Commit

Permalink
Move SVGImage import into conditional stagement
Browse files Browse the repository at this point in the history
SVG image support is optional. By importing the svgimage module at the
top of the image.py module, any rst document that contained an image
would rely on having svglib installed. This commit fixes that problem.
  • Loading branch information
pappasam committed Jun 7, 2019
1 parent d784240 commit ab2c81e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rst2pdf/image.py
Expand Up @@ -13,8 +13,6 @@
from .opt_imports import PILImage, pdfinfo
from .log import log, nodeid

from .svgimage import SVGImage

# This assignment could be overridden by an extension module
VectorPdf = None

Expand Down Expand Up @@ -193,6 +191,7 @@ def get_backend(self, uri, client):

if extension in ['svg','svgz']:
log.info('Backend for %s is SVGIMage'%filename)
from .svgimage import SVGImage
backend=SVGImage

elif extension in ['pdf']:
Expand Down Expand Up @@ -246,6 +245,7 @@ def size_for_node(self, node, client):
xdpi, ydpi = client.styles.def_dpi, client.styles.def_dpi
extension = imgname.split('.')[-1].lower()
if extension in ['svg','svgz']:
from .svgimage import SVGImage
iw, ih = SVGImage(imgname, srcinfo=srcinfo).wrap(0, 0)
# These are in pt, so convert to px
iw = iw * xdpi / 72
Expand Down

0 comments on commit ab2c81e

Please sign in to comment.