### Method

# Rsvg Handle get_intrinsic_dimensions

since: 2.46

#### Declaration [src]

    void
    rsvg_handle_get_intrinsic_dimensions (
      RsvgHandle* handle,
      gboolean* out_has_width,
      RsvgLength* out_width,
      gboolean* out_has_height,
      RsvgLength* out_height,
      gboolean* out_has_viewbox,
      RsvgRectangle* out_viewbox
    )

#### Description [src]

In simple terms, queries the `width`, `height`, and `viewBox` attributes in an SVG document.

If you are calling this function to compute a scaling factor to render the SVG, consider simply using `rsvg_handle_render_document()` instead; it will do the scaling computations automatically.

Before librsvg 2.54.0, the `out_has_width` and `out_has_height` arguments would be set to true or false depending on whether the SVG document actually had `width` and `height` attributes, respectively.

However, since librsvg 2.54.0, `width` and `height` are now geometry properties per the SVG2 specification; they are not plain attributes. SVG2 made it so that the initial value of those properties is `auto`, which is equivalent to specifing a value of `100%`. In this sense, even SVG documents which lack `width` or `height` attributes semantically have to make them default to `100%`. This is why since librsvg 2.54.0, `out_has_width` and `out_has_heigth` are always returned as `TRUE`, since with SVG2 all documents have a default width and height of `100%`.

As an example, the following SVG element has a `width` of 100 pixels and a `height` of 400 pixels, but no `viewBox`. This function will return those sizes in `out_width` and `out_height`, and set `out_has_viewbox` to `FALSE`.

    <svg xmlns="http://www.w3.org/2000/svg" width="100" height="400">

Conversely, the following element has a `viewBox`, but no `width` or `height`. This function will set `out_has_viewbox` to `TRUE`, and it will also set `out_has_width` and `out_has_height` to `TRUE` but return both length values as `100%`.

    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 400">

Note that the `RsvgLength` return values have `RsvgUnits` in them; you should not assume that they are always in pixels. For example, the following SVG element will return width and height values whose `units` fields are `RSVG_UNIT_MM`.

    <svg xmlns="http://www.w3.org/2000/svg" width="210mm" height="297mm">

API ordering: This function must be called on a fully-loaded `handle`. See the section “API ordering” for details.

Panics: this function will panic if the `handle` is not fully-loaded.

Available since: 2.46

#### Parameters

`out_has_width`

  Type: `gboolean*`

  Will be set to `TRUE`; see below.

  The argument will be set by the function.
  The argument can be `NULL`.

`out_width`

  Type: `RsvgLength`

  Will be set to the computed value of the `width` property in the toplevel SVG.

  The argument will be set by the function.
  The argument can be `NULL`.
  The returned data is owned by the instance.

`out_has_height`

  Type: `gboolean*`

  Will be set to `TRUE`; see below.

  The argument will be set by the function.
  The argument can be `NULL`.

`out_height`

  Type: `RsvgLength`

  Will be set to the computed value of the `height` property in the toplevel SVG.

  The argument will be set by the function.
  The argument can be `NULL`.
  The returned data is owned by the instance.

`out_has_viewbox`

  Type: `gboolean*`

  Will be set to `TRUE` if the toplevel SVG has a `viewBox` attribute.

  The argument will be set by the function.
  The argument can be `NULL`.

`out_viewbox`

  Type: `RsvgRectangle`

  Will be set to the value of the `viewBox` attribute in the toplevel SVG.

  The argument will be set by the function.
  The argument can be `NULL`.
  The returned data is owned by the instance.