2

I have a need to load an Image in jQuery SVG but in its original size. The fact is that it is not know as to what is the original size of the image that is getting loaded.

The code that we need to use to load an image is:

svg.image(0, 0, 330, 540, 'images/img1.jpg', {id: 'img'});

Here I have to provide the size of the image. Its compulsory. But I don't know the actual size of the image so what should I do to get the image to load in its original size and a particular location?

Regards,

Yogi Yang

Yogi Yang 007
  • 5,147
  • 10
  • 56
  • 77

1 Answers1

3

Check out this answer to a similar question. Basically, the trick is to load the image outside of the dom, get the dimensions and then add it afterwards.

Community
  • 1
  • 1
nfechner
  • 17,295
  • 7
  • 45
  • 64