How to get the image size (width/height) of an SVG image with batik
<p>How can I get the size (width/height) of an SVG image using batik (1.7)?</p>

<pre><code>String s = "https://openclipart.org/download/228858";
InputStream is = new URL(s).openStream();

DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = f.newDocumentBuilder();
Document doc = builder.parse(is);

SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(doc);
SVGGraphics2D svg = new SVGGraphics2D(ctx,false);

Dimension d = svg.getSVGCanvasSize();
Rectangle r = svg.getClipBounds();

System.out.println(svg.toString()); //org.apache.batik.svggen.SVGGraphics2D[font=java.awt.Font[family=Dialog,name=sanserif,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
System.out.println("Dimension null? "+(d==null)); //true
System.out.println("Rectangle null? "+(r==null)); //true
</code></pre>

<p>The example can be directly executed and is downloading a image from open clipart.org. Alternatively to a absolute size I'm also interested in the aspect ratio of the image.</p>