As stated in the docs, the width
and height
attributes are required for an SVG <image>
.
Now, I just have an image URL. I do not know the graphics size. I would instead like to retrieve it with JavaScript.
As described in an HTML-related question, I can create an Image
object and read the dimensions from there. However, this seems wasteful as (I presume) it loads the image from the specified URL just to get the size, in order to load it again in the SVG <image>
element.
Is there a way to retrieve the PNG graphic size directly via the SVG <image>
element, so I can assign it to the same element's width
and height
properties?