vtracer_buffer 0.6.5

A cmd app to convert images into vector graphics.
Documentation
use std::fs::File;
use std::io::Read;
use image::GenericImageView;



pub fn simple_svg() ->  Result<String, String> {
    // Save the base64 string to a file
    // let output_filename = "test.jpg";
    // let mut file = File::create(output_filename).map_err(|e| format!("File create error: {}", e))?;
    // file.write_all(base64.as_bytes()).map_err(|e| format!("File write error: {}", e));
    // println!("Image saved as {}", output_filename);

    // // Set up input and output paths
    // let input_path = Path::new(output_filename);
    // let output_path = Path::new("src").join("image.svg");

    
    let mut file = File::open("test.jpg").expect("Failed to open image file");

    // Read the contents of the file into a vector of bytes
    let mut buffer = Vec::new();
    file.read_to_end(&mut buffer).expect("Failed to read image file");
    
    // Configure the conversion
    let config = Config {
        color_mode: vtracer_buffer::ColorMode::Color,
        hierarchical: vtracer_buffer::Hierarchical::Stacked,
        filter_speckle: 25,
        color_precision: 8,
        layer_difference: 40,
        mode: Default::default(),
        corner_threshold: 60,
        length_threshold: 10.0,
        max_iterations: 10,
        splice_threshold: 45,
        path_precision: Some(8),
    };

    // Convert image to SVG
    let svg_code = convert_image_to_svg(buffer, config)
        .map_err(|e| format!("SVG conversion error: {}", e));

    println!("SVG conversion successful!");

    svg_code
}

fn main() {
    simple_svg()
}