Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CCITT Group 4 / T.6 "fax machine" compression handling example #211

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

hotspoons
Copy link

The maintainer of the fax crate was gracious enough to help me get CCITT group 4/T.6 compression support working with the tiff crate (see this) and he suggested I offer it as an example here. I'm just taking a guess for how you would want to include an example of this integration, so here it is!

@sophie-h
Copy link

This code looks quite clean. Maybe this could just be added as a feature to tiff? That would make the example redundant.

@fintelia
Copy link
Contributor

Yeah, I'd be in favor of adding this as a feature to tiff. This is where we dispatch on which compression to use:

Ok(match compression_method {
CompressionMethod::None => Box::new(reader),
CompressionMethod::LZW => {
Box::new(LZWReader::new(reader, usize::try_from(compressed_length)?))
}
CompressionMethod::PackBits => Box::new(PackBitsReader::new(reader, compressed_length)),
CompressionMethod::Deflate | CompressionMethod::OldDeflate => {
Box::new(DeflateReader::new(reader))
}
CompressionMethod::ModernJPEG => {

I do think it'll take a bit of effort though. The fax crate seems to sometimes panic if it encounters malformed input and it isn't immediately obvious whether we could handle incremental decompression (which helps both for perf and to avoid OOMs from specially crafted inputs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants