#printing #image #raster #decoding #group #standard #pwg

bin+lib pwgraster

Decoding of PWG (Printer Working Group) raster images

1 unstable release

Uses old Rust 2015

0.1.0 May 28, 2017

#38 in #raster

MIT/Apache

31KB
649 lines

pwgraster

Decoding of Printer Working Group Candidate Standard 5102.4-2012 raster images.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

PWG Raster

Decoding of Printer Working Group Candidate Standard 5102.4-2012 raster images.

Decoding multiple pages

next_page() will call a closure with a page structure that allows access to the header and page data. It will return Ok(None) when there are no more pages.

use std::fs::File;
use std::io::BufReader;
use pwgraster::PWGReader;
let infile = File::open("./color.jpg-4x6-srgb-8-600dpi.pwg")
                 .expect("Failed to open input");
let mut pwg = PWGReader::new(BufReader::new(infile), true).unwrap();
while pwg.next_page(|page| {
        let width = page.header().Width().unwrap();
        let height = page.header().Height().unwrap();
        println!("Page dimensions {}x{}", width, height);
        let mut buf = Vec::with_capacity(page.header().image_size_bytes().unwrap());
        println!("Reading page");
        page.unpack(&mut buf).unwrap();
        println!("Page read");
        // Do something with image data
        Ok(())
    }).unwrap().is_some() {}

Dependencies

~1MB
~18K SLoC