Debian Codegraph @

.cargo/vendor/fax/examples/fax2tiff.rs

raw
1 use fax::tiff::wrap;
2 use fax::{VecWriter, decoder, decoder::pels, BitWriter, Bits, Color};
3 use std::io::Write;
4 use std::fs::{self, File};
5
6 fn main() {
7 let mut args = std::env::args().skip(1);
8 let input: String = args.next().unwrap();
9 let width: u16 = args.next().unwrap().parse().unwrap();
10 let output = args.next().unwrap();
11
12 let data = fs::read(&input).unwrap();
13 let mut height = 0;
14 decoder::decode_g4(data.iter().cloned(), width, None, |transitions| {
15 height += 1;
16 });
17
18 std::fs::write(output, wrap(&data, width as _, height)).unwrap();
19 }