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

Don't panic when parsing metadata when custom compression is used #203

Merged
merged 1 commit into from
Mar 8, 2023

Conversation

AlanRace
Copy link
Contributor

@AlanRace AlanRace commented Mar 7, 2023

Some microscopy file types, such as .svs (https://openslide.org/formats/aperio/) are essentially .tif files, with custom tags. I wanted to read in the metadata (width, height etc.), but this failed due to the file using a custom compression scheme (JPEG2000) that is not supported in the image-tiff library/.tif specification.

This PR simply adds in the ability to read in custom compression schemes and therefore also the metadata, without an error occuring.

@fintelia
Copy link
Contributor

fintelia commented Mar 7, 2023

What happens if you try to read the file contents when an unsupported scheme is used? Do we still properly return an error?

@AlanRace
Copy link
Contributor Author

AlanRace commented Mar 8, 2023

Good question - yes. When running the following code:

let svs_file = File::open(svs_path)?;
let mut decoder = Decoder::new(BufReader::new(svs_file))?;

println!("Dimensions: {:?}", decoder.dimensions());

let chunk = decoder.read_chunk(0)?;

I get:

Dimensions: Ok((39840, 28523))
Error: UnsupportedError(UnsupportedCompressionMethod(Unknown(33005)))

@HeroicKatora HeroicKatora merged commit aefea77 into image-rs:master Mar 8, 2023
@AlanRace AlanRace deleted the custom-compression branch March 8, 2023 10:00
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.

3 participants