#svg #graphics #image #metadata

svg_metadata

Extracts metadata (like the viewBox, width, and height) from SVG graphics

7 unstable releases

0.4.2 Dec 26, 2020
0.4.1 Jun 11, 2020
0.3.0 Aug 24, 2019
0.2.1 Aug 21, 2019
0.1.0 Aug 14, 2019

#27 in Multimedia

Download history 107/week @ 2021-06-30 168/week @ 2021-07-07 229/week @ 2021-07-14 263/week @ 2021-07-21 227/week @ 2021-07-28 261/week @ 2021-08-04 162/week @ 2021-08-11 279/week @ 2021-08-18 167/week @ 2021-08-25 212/week @ 2021-09-01 213/week @ 2021-09-08 82/week @ 2021-09-15 126/week @ 2021-09-22 125/week @ 2021-09-29 113/week @ 2021-10-06 124/week @ 2021-10-13

744 downloads per month

Apache-2.0/MIT

490KB
370 lines

svg-metadata

Github Actions Documentation

What is it?

This crate extracts metadata from SVG files. Currently it reads the following attributes:

  • viewBox
  • width
  • height

You can add more!

Usage Example

use svg_metadata::{Metadata, ViewBox};

fn main() {
    let svg = r#"<svg viewBox="0 1 99 100" xmlns="http://www.w3.org/2000/svg">
    <rect x="0" y="0" width="100%" height="100%"/>
    </svg>"#;

    let meta = Metadata::parse(svg).unwrap();
    assert_eq!(
        meta.view_box,
        Some(ViewBox {
            min_x: 0.0,
            min_y: 1.0,
            width: 99.0,
            height: 100.0
        })
    );
}

(You can also parse files directly with parse_file().)

Credits

The SVG fixtures used for testing are provided by

under their respective licenses.

Dependencies

~1.5MB
~42K SLoC