title: Get SVG Image Dimensions in JavaScript
body: <p>As stated in the <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/image" rel="nofollow noreferrer">docs</a>, the <code>width</code> and <code>height</code> attributes are required for an SVG <code>&lt;image&gt;</code>.</p>
  
  <p>Now, I just have an image URL. I do not know the graphics size. I would instead like to retrieve it with JavaScript.</p>
  
  <p>As described in an <a href="https://stackoverflow.com/questions/5633264/javascript-get-image-dimensions">HTML-related question</a>, I can create an <code>Image</code> 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 <code>&lt;image&gt;</code> element.</p>
  
  <p><strong>Is there a way to retrieve the PNG graphic size directly via the SVG <code>&lt;image&gt;</code> element, so I can assign it to the same element's <code>width</code> and <code>height</code> properties?</strong></p>