diff --git a/src/lib.rs b/src/lib.rs index 84063d1..efdb0b5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,7 +34,7 @@ pub fn svgify(input: &DynamicImage) -> Result { let y_pos = box_offset.1 + 5 + y * 5; let c = Circle::new() .set("stroke", "black") - .set("stroke-width", 0.1) + .set("stroke-width", 0.05) .set("cx", x_pos) .set("cy", y_pos); @@ -59,7 +59,7 @@ pub fn svgify(input: &DynamicImage) -> Result { .set("width", 150) .set("height", 150) .set("stroke", "black") - .set("stroke-width", 0.1) + .set("stroke-width", 0.05) .set("x", box_offset.0) .set("y", box_offset.1) .set("rx", 1) diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index 8c10256..0000000 --- a/src/main.rs +++ /dev/null @@ -1,46 +0,0 @@ -use std::fs::File; -use std::io; -use std::io::Write; -use std::path::PathBuf; - -use anyhow::Result; -//use image::imageops::colorops::{index_colors, BiLevel}; -//use image::math::nq::NeuQuant; -//use image::DynamicImage; -use structopt::StructOpt; - -use perler::{simplify, svgify}; - -/// Convert image to SVG in the style of perler instructions. -#[derive(StructOpt, Debug)] -#[structopt(name = "perler")] -struct Opt { - /// Input image file. - input: PathBuf, - /// Optional output .svg file. Default prints to stdout. - output: Option, -} - -fn main() -> Result<()> { - let opt = Opt::from_args(); - let img = image::open(opt.input)?; - /* - let mut img2 = img.to_rgba(); - let raw = img.into_rgba().into_raw(); - - let cmap = NeuQuant::new(1, 256, &raw); - index_colors(&mut img2, &cmap); - - let img = DynamicImage::ImageRgba8(img2.into()); - */ - let img = simplify(&img); - let out_svg = svgify(&img)?; - let w: Box = if let Some(path) = opt.output { - Box::new(File::create(path)?) - } else { - Box::new(io::stdout()) - }; - svg::write(w, &out_svg)?; - - Ok(()) -}