python again

This commit is contained in:
Chris Tsang
2023-09-16 17:59:52 +01:00
parent 79dd451da1
commit f5cce867f2

View File

@@ -1,11 +1,12 @@
use crate::*;
use pyo3::prelude::*; use pyo3::prelude::*;
use std::path::PathBuf;
use visioncortex::{PathSimplifyMode}; use visioncortex::PathSimplifyMode;
use super::converter::*;
/// Python binding /// Python binding
#[pyfunction] #[pyfunction]
fn convert_image_to_svg_py( image_path: &str, fn convert_image_to_svg_py(
image_path: &str,
out_path: &str, out_path: &str,
colormode: Option<&str>, // "color" or "binary" colormode: Option<&str>, // "color" or "binary"
hierarchical: Option<&str>, // "stacked" or "cutout" hierarchical: Option<&str>, // "stacked" or "cutout"
@@ -17,7 +18,7 @@ fn convert_image_to_svg_py( image_path: &str,
length_threshold: Option<f64>, // in [3.5, 10] default: 4.0 length_threshold: Option<f64>, // in [3.5, 10] default: 4.0
max_iterations: Option<usize>, // default: 10 max_iterations: Option<usize>, // default: 10
splice_threshold: Option<i32>, // default: 45 splice_threshold: Option<i32>, // default: 45
path_precision: Option<u32> // default: 8 path_precision: Option<u32>, // default: 8
) -> PyResult<()> { ) -> PyResult<()> {
let input_path = PathBuf::from(image_path); let input_path = PathBuf::from(image_path);
let output_path = PathBuf::from(out_path); let output_path = PathBuf::from(out_path);
@@ -68,7 +69,6 @@ fn convert_image_to_svg_py( image_path: &str,
..Default::default() ..Default::default()
}; };
convert_image_to_svg(config).unwrap(); convert_image_to_svg(config).unwrap();
Ok(()) Ok(())
} }