Add support for iterating over all tags (#255)
This commit is contained in:
1 parent
96d3a02efe
commit
ff52aea06e
2 files changed
+95
-5
No files matched your search
+13
-5
@@ -1,17 +1,16 @@
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::io::{self, Read, Seek};
|
||||
|
||||
use crate::tags::{
|
||||
CompressionMethod, PhotometricInterpretation, PlanarConfiguration, Predictor, SampleFormat,
|
||||
Tag, Type,
|
||||
};
|
||||
use crate::{
|
||||
bytecast, ColorType, TiffError, TiffFormatError, TiffResult, TiffUnsupportedError, UsageError,
|
||||
};
|
||||
|
||||
use self::ifd::Directory;
|
||||
use self::image::Image;
|
||||
use crate::tags::{
|
||||
CompressionMethod, PhotometricInterpretation, PlanarConfiguration, Predictor, SampleFormat,
|
||||
Tag, Type,
|
||||
};
|
||||
|
||||
use self::stream::{ByteOrder, EndianReader, SmartReader};
|
||||
|
||||
pub mod ifd;
|
||||
@@ -895,6 +894,15 @@ impl<R: Read + Seek> Decoder<R> {
|
||||
self.get_tag(tag)?.into_string()
|
||||
}
|
||||
|
||||
/// Returns an iterator over all tags in the current image, along with their values.
|
||||
pub fn tag_iter(&mut self) -> impl Iterator<Item = TiffResult<(Tag, ifd::Value)>> + '_ {
|
||||
self.image.ifd.as_ref().unwrap().iter().map(|(tag, entry)| {
|
||||
entry
|
||||
.val(&self.limits, self.bigtiff, &mut self.reader)
|
||||
.map(|value| (*tag, value))
|
||||
})
|
||||
}
|
||||
|
||||
fn check_chunk_type(&self, expected: ChunkType) -> TiffResult<()> {
|
||||
if expected != self.image().chunk_type {
|
||||
return Err(TiffError::UsageError(UsageError::InvalidChunkType(
|
||||
|
||||
Reference in new issue
Block a user