Files
stitch-peek-rs/stitch-peek/src/main.rs
Nils Pukropp 7c8ecda29a
Some checks failed
CI / Lint and Test (pull_request) Successful in 44s
CI / Version Check (pull_request) Failing after 3s
fixed bug with color layering issue
2026-03-31 12:18:53 +02:00

41 lines
1.1 KiB
Rust

use anyhow::{Context, Result};
use clap::Parser;
use std::fs;
#[derive(Parser)]
#[command(
name = "stitch-peek",
about = "Embroidery file thumbnailer (PES, DST, EXP, JEF, VP3)"
)]
struct Args {
/// Input embroidery file path
#[arg(short = 'i', long = "input")]
input: std::path::PathBuf,
/// Output PNG file path
#[arg(short = 'o', long = "output")]
output: std::path::PathBuf,
/// Thumbnail size in pixels
#[arg(short = 's', long = "size", default_value = "128")]
size: u32,
}
fn main() -> Result<()> {
let args = Args::parse();
let format = rustitch::format::detect_from_extension(&args.input)
.with_context(|| format!("unsupported file extension: {}", args.input.display()))?;
let data = fs::read(&args.input)
.with_context(|| format!("failed to read {}", args.input.display()))?;
let png = rustitch::thumbnail_format(&data, args.size, format)
.with_context(|| "failed to generate thumbnail")?;
fs::write(&args.output, &png)
.with_context(|| format!("failed to write {}", args.output.display()))?;
Ok(())
}