Bug 49052 - -dpi setting does not work well.
Summary: -dpi setting does not work well.
Status: RESOLVED INVALID
Alias: None
Product: Batik - Now in Jira
Classification: Unclassified
Component: SVG Rasterizer (show other bugs)
Version: 1.7
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: Batik Developer's Mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-06 10:29 UTC by Peter Hull
Modified: 2010-04-06 10:49 UTC (History)
0 users



Attachments
zip containing 'good' and 'bad' svg files and pngs at 100 and 200dpi (22.00 KB, application/x-zip-compressed)
2010-04-06 10:29 UTC, Peter Hull
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Hull 2010-04-06 10:29:24 UTC
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>
Comment 1 Thomas Deweese 2010-04-06 10:49:10 UTC
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.