doesn't work lol

This commit is contained in:
Breval Ferrari 2025-03-22 23:09:21 -04:00
parent 308e3a9d11
commit 0ac3340373
No known key found for this signature in database
GPG key ID: F71E304D6400AB8E
3 changed files with 19 additions and 22 deletions

View file

@ -1,2 +1,2 @@
pub use printpdf::PdfDocument; pub use printpdf;
mod pdf; mod pdf;

View file

@ -11,5 +11,6 @@ keywords.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
anyhow = "1.0.97"
bingus = { path = "../bingus" } bingus = { path = "../bingus" }
clap = { version = "4.5.32", features = ["derive"] } clap = { version = "4.5.32", features = ["derive"] }

View file

@ -1,31 +1,27 @@
use std::fs::File;
use anyhow::{anyhow, Context, Error};
use bingus::{ use bingus::{
img::{Dimensions, RgbImage}, doc::printpdf::{FontId, Op, PdfDocument, TextItem},
snd::RawSamples, Bendable,
Bendable, DynamicBendable, OpenError,
}; };
use clap::Parser; use clap::Parser;
use cli::Cli; use cli::Cli;
mod cli; mod cli;
fn main() -> Result<(), OpenError> { fn main() -> Result<(), Error> {
let args = Cli::parse(); let args = Cli::parse();
if let DynamicBendable::Image(i) = File::open(args.input_file)
bingus::open(args.input_file)?.expect("could not open this file.") .context("opening file")?
{ .bend_into::<PdfDocument>((), Default::default())
let dimensions = Dimensions { .map_err(|e| anyhow!("parsing PDF: {e}"))?
width: i.width(), .map(|t| Op::WriteText {
height: i.height(), items: vec![TextItem::Text(String::from("h"))],
}; font: FontId::new(),
RawSamples::<u32>::bend_from(i, (), bingus::Crop::End) })
.unwrap() .bend_into::<File>(Box::new(args.output_file), Default::default())
.map(|s| s.abs_diff(s.wrapping_neg())) .context("saving output file")?;
.bend_into::<RgbImage>(dimensions, bingus::Crop::End)
.unwrap()
.save(args.output_file)
.unwrap();
} else {
println!("Not an image! Sorry!");
}
Ok(()) Ok(())
} }