Expand description
The is-svg crate is a library for testing whether a given data is a SVG
image.
This crate assumes the given data to be a valid SVG image if
usvg::Tree::from_data returns Ok, and an invalid SVG image if it
returns Err. It supports both a SVG string and a gzip-compressed SVG
data.
§Examples
assert_eq!(
is_svg::is_svg(include_str!("../tests/data/w3/svg-logo-v.svg")),
true
);
assert_eq!(
is_svg::is_svg(include_bytes!("../tests/data/w3/svg-logo-v.png")),
false
);
// `.svgz` is also supported.
assert_eq!(
is_svg::is_svg(include_bytes!("../tests/data/w3/svg-logo-v.svgz")),
true
);Functions§
- is_svg
- Returns
trueifdatais a valid SVG data, andfalseotherwise. - is_
svg_ string - Returns
trueifdatais a valid non gzip-compressed SVG data (.svg), andfalseotherwise. - is_svgz
- Returns
trueifdatais a valid gzip-compressed SVG data (.svgz), andfalseotherwise.