I frequently use SVGs with a viewBox
set to the image dimensions and the width
and height
set to 100%
. This causes the displayed image to size to the display:
When images in that format are fed to canvg, they don't render correctly:
One method of getting a correct render is to load the image, compute a height and width and set them prior to rendering:
This is done with the function: