Crate usvg_remote_resolvers

Crate usvg_remote_resolvers 

Source
Expand description

Provides a way to resolve the href attribute of the <image> tag in the SVG for usvg.

§Example

use usvg::Options;
use usvg_remote_resolvers::{HrefStringResolver, reqwest_blocking::BlockingReqwestResolver};

let resolver = BlockingReqwestResolver::default();
let mut options = Options::default();
resolver.set_into_options(&mut options);

let tree = usvg::Tree::from_str(
    r#"<svg xmlns="http://www.w3.org/2000/svg">
        <image href="https://example.com/sample.png" />
    </svg>"#,
    &options,
).unwrap();

let mut pixmap = resvg::tiny_skia::Pixmap::new(200, 200).unwrap();
resvg::render(
    &tree,
    resvg::tiny_skia::Transform::identity(),
    &mut pixmap.as_mut(),
);

§Feature Flags

  • reqwest: Enable the reqwest resolver.
  • reqwest_blocking: Enable the reqwest_blocking resolver.

Modules§

reqwest
reqwest_blocking

Structs§

DefaultResolver
Resolver using default_string_resolver
FallbackResolver

Traits§

HrefStringResolver
HrefStringResolver is a trait that is used to resolve the href attribute of the <image> tag. It will be converted to ImageHrefResolver to be set in the Options.