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
29
30
31
32
33
34
35
36
37
38
39
40
41
//! # dxf2image
//!
//! `dxf2image` is a fast and efficient dxf to image converter!
//!
//! ## Usage
//!
//! ``` no_run
//! use dxf2image::{dxf2svg, dxf2png};
//!
//! fn main() {
//!     let dxf = "sample.dxf";
//!
//!     // Convert to svg
//!     let svg = "sample.svg";
//!     dxf2svg(dxf, svg).unwrap();
//!
//!     // Convert to png
//!     let png = "sample.png";
//!     dxf2png(dxf, png).unwrap();
//! }
//! ```

mod color;
mod coord;
mod dxf2svg;
#[cfg(feature = "png")]
mod svg2png;

pub use dxf2svg::dxf2svg;

#[cfg(feature = "png")]
pub use svg2png::svg2png;

#[cfg(feature = "png")]
/// Convert dxf to png
pub fn dxf2png(input_path: &str, output_path: &str) -> anyhow::Result<()> {
    // FIXME: use tmpfile
    dxf2svg(input_path, output_path)?;
    svg2png(output_path, output_path)?;
    Ok(())
}