image-tiff
image-tiff copied to clipboard
API overhaul
I think that the current api of this crate is sort of messy and a overhaul would be nice. I think this crate should be structured for two use cases: a low-level usage of the tiff format with direct control over tags and data and a mid-level baseline tiff implementation with access to properties specified by baseline tiff (and possibly some more). The high-level use case should be covered by the image crate.
Two things that I think would improve the api a lot would be to reorganize all the small helper types so that they fit together well with both the decoder and encoder and clean up decoder api.
I propose something like this for the decoding api:
impl TiffDecoder<R> {
fn new(...) {...}
fn next_directory<'a>(&'a mut self) -> TiffResult<Option<Directory<'a>>> {...}
fn prev_directory<'a>(&'a mut self) -> TiffResult<Option<Directory<'a>>> {...}
fn next_image<'a>(&'a mut self) -> TiffResult<Option<Image<'a>>> {...}
fn prev_image<'a>(&'a mut self) -> TiffResult<Option<Image<'a>>> {...}
}
impl DirectoryDecoder {
fn read_tag(&mut self, tag: Tag) -> Entry {...}
fn read_data<T: TiffValue>(&mut self, offset: u32, buffer: &mut T) -> TiffResult<()> {...}
}
impl ImageDecoder {
fn width(&self) -> u32 {...}
fn height(&self) -> u32 {...}
fn pixel_format(&self) -> PixelFormat {...}
fn read_strip(&mut self) -> DecodingResult {...} // ???
fn reader<'a>(&'a mut self) -> Reader<'a> {...}
fn resolution_unit(&mut self) -> ResolutionUnit {...}
fn x_resolution(&self) -> Rational {...}
fn y_resolution(&self) -> Rational {...}
// Other baseline tiff properties ...
}