-
Notifications
You must be signed in to change notification settings - Fork 658
Added compression and f32 support for TIFF encoding/decoding. #2251
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,59 @@ where | |
} | ||
} | ||
|
||
#[cfg(feature = "tiff")] | ||
#[test] | ||
fn tiff_compress_deflate() { | ||
use image::codecs::tiff::{CompressionType, TiffDeflateLevel, TiffEncoder}; | ||
|
||
process_images(IMAGE_DIR, Some("tiff"), |_base, path, _| { | ||
println!("compress_images {}", path.display()); | ||
let img = match image::open(&path) { | ||
Ok(img) => img, | ||
// Do not fail on unsupported error | ||
// This might happen because the testsuite contains unsupported images | ||
// or because a specific decoder included via a feature. | ||
Err(image::ImageError::Unsupported(e)) => { | ||
println!("UNSUPPORTED {}: {e}", path.display()); | ||
return; | ||
} | ||
Err(err) => panic!("decoding of {path:?} failed with: {err}"), | ||
}; | ||
|
||
let encoder = TiffEncoder::new_with_compression( | ||
std::io::Cursor::new(vec![]), | ||
CompressionType::Deflate(TiffDeflateLevel::Balanced), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How long does this test take? I could imagine that compressing all the input files with balanced compression could take a while, though I don't know how many / how large they are. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
); | ||
|
||
img.write_with_encoder(encoder).unwrap(); | ||
}) | ||
} | ||
|
||
#[cfg(feature = "tiff")] | ||
#[test] | ||
fn tiff_compress_lzw() { | ||
use image::codecs::tiff::{CompressionType, TiffEncoder}; | ||
|
||
process_images(IMAGE_DIR, Some("tiff"), |_base, path, _| { | ||
println!("compress_images {}", path.display()); | ||
let img = match image::open(&path) { | ||
Ok(img) => img, | ||
// Do not fail on unsupported error | ||
// This might happen because the testsuite contains unsupported images | ||
// or because a specific decoder included via a feature. | ||
Err(image::ImageError::Unsupported(e)) => { | ||
println!("UNSUPPORTED {}: {e}", path.display()); | ||
return; | ||
} | ||
Err(err) => panic!("decoding of {path:?} failed with: {err}"), | ||
}; | ||
|
||
let encoder = | ||
TiffEncoder::new_with_compression(std::io::Cursor::new(vec![]), CompressionType::Lzw); | ||
img.write_with_encoder(encoder).unwrap(); | ||
}) | ||
} | ||
|
||
#[cfg(feature = "png")] | ||
#[test] | ||
fn render_images() { | ||
|
Uh oh!
There was an error while loading. Please reload this page.