svg_metadata

Crates.iosvg_metadata
lib.rssvg_metadata
version0.5.1
sourcesrc
created_at2019-08-14 08:32:48.590819
updated_at2024-05-28 08:18:34.597213
descriptionExtracts metadata (like the viewBox, width, and height) from SVG graphics
homepagehttps://github.com/mre/svg-metadata
repository
max_upload_size
id156704
size1,698,657
Matthias Endler (mre)

documentation

README

svg-metadata

CI 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.

Commit count: 0

cargo fmt