temporary FIX: drawToPMCanvas -> dpi ignored #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi there,
when creating a raster image from an SVG with dpi values different then 72, the image range is scaled, but not the image itself.
Version used: 0.8.1
Minimum working example:
`
import numpy as np
from lxml import etree
from svglib.svglib import SvgRenderer
from reportlab.graphics import renderPM
import pylab as plt
s = ''' <svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.1"
width="100mm"
height="100mm" >
aaaaa
bbb
'''.encode('UTF-8')
parser = etree.XMLParser(remove_comments=True, recover=True)
xml = etree.fromstring(s, parser=parser)
for dpi in (72, 150, 300):
drw = SvgRenderer('_tempfile.svg').render(xml)
pil = renderPM.drawToPIL(drw, dpi=dpi)
plt.figure(dpi)
plt.imshow(np.array(pil))
plt.show()
`
This generated the following output:
Output after fix:
I am sure that there is a better way ... such as incorporating d.renderScale (in renderScaledDrawing) right