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

Group 4/ T.6 Tiff example #4

Closed
hotspoons opened this issue Aug 18, 2023 · 6 comments
Closed

Group 4/ T.6 Tiff example #4

hotspoons opened this issue Aug 18, 2023 · 6 comments

Comments

@hotspoons
Copy link

I know there is already issue #1 regarding this, but please hear me out. I spent a non-insignificant amount of time and effort to try to do something I take for granted in more established languages/runtimes like Java and Python - load an arbitrary .tiff file and expect it to successfully decode to a bitmap or other readily accessible structure. My specific use case involves 1 bit CCITT group 4-compressed tiff files, which are still commonly used in government and industry.

The main image crate won't even try to recognize this format; the tiff crate fails as soon as this compression type is encountered; and every other CCITT implementation I've encountered is too low level for someone low on the Rust talent totem pole like me.

This project seemed like the closest to fulfilling this need out of everything I've tried thus far (outside of an ImageMagick wrapper for rust, which would totally work) and is painfully close to being able to provide an example that would work maybe in conjunction with the tiff crate that can parse out the metadata from the underlying tiff image.

When I tried to send it, just stuff a raw .tiff file as Vec into decoder::decode_g4 per the pbm example, it ended up reading half of the width of the image on one scan line and quitting.

Any help would be appreciated!

@s3bk
Copy link
Collaborator

s3bk commented Aug 18, 2023

Can you share the file?

@hotspoons
Copy link
Author

I'll do you one better - I extracted this problem from my application and put it in a repository here - and here is where I call into a method that I extracted from your pbm example. I am aware that the bitmap returned would need more manipulation to be usable by the image crate, this is just for demonstration purposes only.

This is a passing case (source .png file), and this is the failing case I was reaching out about (png contents flattened to 1 bit and exported as a tif using group 4 compression).

Thank you so much for looking at this!!

@s3bk
Copy link
Collaborator

s3bk commented Aug 19, 2023

It isn't that difficult. Just feed the strips into the decoder.
hotspoons/tiff-issue@main...s3bk:tiff-issue:main

@hotspoons
Copy link
Author

You're a rockstar, thank you so much!! Can I reciprocate with a PR containing a simplified example of this implementation (just the tiff part, no scaling)? And how would you suggest I handle additional external dependencies for the example?

@s3bk
Copy link
Collaborator

s3bk commented Aug 20, 2023

How about making the example part of the tiff crate? Or even integrating it into it?

@hotspoons
Copy link
Author

I'll start with an example, which I PR'ed here. Thanks again!

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

No branches or pull requests

2 participants