doesn't work lol
This commit is contained in:
parent
308e3a9d11
commit
0ac3340373
3 changed files with 19 additions and 22 deletions
|
@ -1,2 +1,2 @@
|
|||
pub use printpdf::PdfDocument;
|
||||
pub use printpdf;
|
||||
mod pdf;
|
||||
|
|
|
@ -11,5 +11,6 @@ keywords.workspace = true
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.97"
|
||||
bingus = { path = "../bingus" }
|
||||
clap = { version = "4.5.32", features = ["derive"] }
|
||||
|
|
|
@ -1,31 +1,27 @@
|
|||
use std::fs::File;
|
||||
|
||||
use anyhow::{anyhow, Context, Error};
|
||||
use bingus::{
|
||||
img::{Dimensions, RgbImage},
|
||||
snd::RawSamples,
|
||||
Bendable, DynamicBendable, OpenError,
|
||||
doc::printpdf::{FontId, Op, PdfDocument, TextItem},
|
||||
Bendable,
|
||||
};
|
||||
use clap::Parser;
|
||||
use cli::Cli;
|
||||
|
||||
mod cli;
|
||||
|
||||
fn main() -> Result<(), OpenError> {
|
||||
fn main() -> Result<(), Error> {
|
||||
let args = Cli::parse();
|
||||
if let DynamicBendable::Image(i) =
|
||||
bingus::open(args.input_file)?.expect("could not open this file.")
|
||||
{
|
||||
let dimensions = Dimensions {
|
||||
width: i.width(),
|
||||
height: i.height(),
|
||||
};
|
||||
RawSamples::<u32>::bend_from(i, (), bingus::Crop::End)
|
||||
.unwrap()
|
||||
.map(|s| s.abs_diff(s.wrapping_neg()))
|
||||
.bend_into::<RgbImage>(dimensions, bingus::Crop::End)
|
||||
.unwrap()
|
||||
.save(args.output_file)
|
||||
.unwrap();
|
||||
} else {
|
||||
println!("Not an image! Sorry!");
|
||||
}
|
||||
File::open(args.input_file)
|
||||
.context("opening file")?
|
||||
.bend_into::<PdfDocument>((), Default::default())
|
||||
.map_err(|e| anyhow!("parsing PDF: {e}"))?
|
||||
.map(|t| Op::WriteText {
|
||||
items: vec![TextItem::Text(String::from("h"))],
|
||||
font: FontId::new(),
|
||||
})
|
||||
.bend_into::<File>(Box::new(args.output_file), Default::default())
|
||||
.context("saving output file")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue