xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Woods, Christopher" <cwo...@EO.Kollmorgen.com>
Subject RE: Svg to png rasterizer resolution - output blurry
Date Wed, 11 Jan 2006 15:02:11 GMT
Thanks to Andreas and Jay for their replies as it turns out their advice
was correct but my problem was one entirely different from what I
described in the first post to this thread.

A typical root from my batch of svgs looks like this:

<svg width="856.085" height="317.649" viewBox="0 0 856.085 317.649"> 

The result from Batik without specifying -h, -w, or -dpi options is
perfectly clear.  I discovered this by viewing the files outside the
publication they belong to (note-to-self: ALWAYS CHECK THE FILE OUTSIDE

The poor resolution was the result of the height and width attributes in
the <img/> tag in the target publication which caused the image to be
stretched to fit a space larger than its original output dimensions.
Thus the blurry output.  I'm going back to re-write the applicable
portion of the XSL transform so that the <img/> tag attributes do not
exceed the actual image dimensions.

In the end the problem lay in the XSL transform that produced the XHTML
page the image belonged to and not the image itself.  Batik works like a
top; my troubleshooting methodology on the other hand...

Thanks again to Jay and Andreas for taking the time to reply to my first



-----Original Message-----
From: Andreas Neumann [mailto:neumann@karto.baug.ethz.ch] 
Sent: Tuesday, January 10, 2006 6:10 PM
To: batik-users@xmlgraphics.apache.org
Subject: Re: Svg to png rasterizer resolution - output blurry


if you have a svg-root element like you specified (

<svg viewBox="2.145927 -6.520668 1.79657 1.452484" width="100%"
height="100%" ... >


, you don't need to replace the width and height to a certain value. No
need to pre-process the SVGs. Note that you need a viewBox and need to
set the width and height to "100%".

Just use the -w and -h switches of the batik rasterizer as documented at

As an example, open the samples/mapSpain.svg file that comes with the
batik distribution and edit the width and height attribute to set it to

Then start the rasterizer as follows:

java -jar batik-rasterizer.jar -w 6000 -h 4200 samples/mapSpain.svg -m
image/png -d spain.png -bg

and you get a crisp output in png that scales to your given width and
height in pixel.

Please note that you need to increase the amount of memory that the
batik-rasterizer has at hand if you want to process medium to big file
sizes or big raster files as output.

Another option to "scale" your image to a given width and height is to
write a wrapper xsl-fo document and include the svg there. That way you
can also generate multipage documents.

Hope, this helps,


Andreas Neumann - Institute of Cartography Swiss Federal Institute of
Technology (ETH) ETH Hoenggerberg
CH-8093  Zurich, Switzerland
Phone: ++41-1-633 3031, Fax: ++41-1-633 1153
e-mail: neumann@karto.baug.ethz.ch
www: http://www.carto.net/neumann/
SVG.Open: http://www.svgopen.org/
Carto.net: http://www.carto.net/

To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org

To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org

View raw message