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;
|
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
|
# 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"] }
|
||||||
|
|
|
@ -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(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue