1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use std::io::Result;
use std::path::Path;
pub fn rasterize(source: &Path, zoom: f32, destination: &Path) -> Result<()> {
#[cfg(feature = "embed-svg")]
{
let tree = usvg::Tree::from_file(source, &usvg::Options::default()).unwrap();
let image = resvg::render(&tree, usvg::FitTo::Zoom(zoom), None).unwrap();
image.save_png(destination).unwrap();
Ok(())
}
#[cfg(not(feature = "embed-svg"))]
{
use std::process::Command;
assert!(Command::new("resvg")
.arg("-z")
.arg(format!("{}", zoom))
.args(&[source, destination])
.status()?
.success());
Ok(())
}
}