Support strip size > 8kB
tnl-rwa opened this issue · comments
In ImageEncoder::new() the strip size of the image data in the tiff is limited to 8kB, with the remark it is per tiff spec. But the tiff spec of 1992(!!) states a recommendation for the 8kB as mitigation for out of memory errors. At time has passed 8kB is ridiculous small.
I bumped into this as I faced performance issues in the Python Pillow library. We have an application retrieving rectangular parts from large images. I noticed that the performance of images generated via the image-tiff crate was ten time slower than images created by Pillow itself. It appeared that Pillow stored the image as a single strip, whil image-tiff stored one line per strip.
I would like to see an option to store the image in a single strip, configure the max strip size or even get rid of the 8kB strip limit.
https://github.com/image-rs/image-tiff/blob/master/src/encoder/mod.rs#L625
When agreed on a solution, I'll implement it myself.
Just to note what Python's tifffile
(which is a great lib) does here:
rowsperstrip : int
The number of rows per strip. By default, strips are ~64 KB if
compression is enabled, else rowsperstrip is set to the image
length.
I agree it should be configurable with more sensible defaults that handle the typical uses of one plane-per-strip and strip'd but modernly sized (64KB seems nice), e.g., by a config enum of ContiguousPlanes/RowsPerStrip(u32)/StripSize(u32)
You are doing a great job on the TIFF library in Rust. Thank you very much for pulling my request in the archive.
Will there be a version 0.6.1 soon, containing the latest fixes? I would like to integrate it into my project.
On Friday or the weekend most likely. If it's pressing you can use a git
source for the dependency.