Created attachment 25234 [details] zip containing 'good' and 'bad' svg files and pngs at 100 and 200dpi If an SVG file contains a width/height in 'real' units but no viewBox attribute on the svg tag, and the image contains graphics in pixel units, the rasterizer works ok if the -dpi command line parameter is 100 but not otherwise when converting to raster formats. If, for example, the dpi is set to 200 the image is physically twice the size but the graphic is not, it stays in the top left hand corner. Rasterizer must be using an implicit DPI of 100 to draw the graphic so it probably should generate an implicit viewBox based on the width/height. As far as I can see the viewBox is not required by SVG and the observed behaviour is not in the SVG spec, apologies if I have missed it. This file is affected <?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns="http://www.w3.org/2000/svg" height="10cm" version="1.1" width="10cm"> <rect height="350" fill="#d8d8d8" stroke="black" width="350" x="25" y="25"/> </svg> With an added viewBox it works correctly <?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns="http://www.w3.org/2000/svg" height="10cm" version="1.1" width="10cm" viewBox="0 0 394 394"> <rect height="350" fill="#d8d8d8" stroke="black" width="350" x="25" y="25"/> </svg>
It sounds like the '-dpi' switch is working fine. The 'dpi' switch changes the mapping from realworld units to userspace units. Not the other way around. So without the viewBox attribute you are changing the effective width and height of the SVG in userspace but your document uses the same portion of the userspace.