I have a GWT application that generates SVG files.
I want to embed an image from some URL into my SVG, but I want it to be resized keeping the correct aspect ratio.
I do this by loading the image using the Image class in GWT, and check the height to width, then do some sums to find the height and width I need it to be in my SVG.
I embed the image into the SVG as follows:
<image href="http://some.image/URL.png" height="100" x="50" width="150" y="50"></image>
The issue that I have is when I do the following:
Image image = new Image(sourceURL);
int width = image.getWidth();
int height = image.getHeight();
....
The first time I do this for a particular URL the value of width or height comes back as 0. Unfortunately retrying in a loop doesn't seem to fix the problem, but if I ask my application to generate the SVG again, it works.
Any ideas?