@@ -111,12 +111,13 @@ impl TiffMetadataReader {
111111 pub async fn read_next_ifd < F : MetadataFetch > (
112112 & mut self ,
113113 fetch : & F ,
114+ extra_tags_registry : ExtraTagsRegistry ,
114115 ) -> AsyncTiffResult < Option < ImageFileDirectory > > {
115116 if let Some ( ifd_start) = self . next_ifd_offset {
116117 let ifd_reader =
117118 ImageFileDirectoryReader :: open ( fetch, ifd_start, self . bigtiff , self . endianness )
118119 . await ?;
119- let ifd = ifd_reader. read ( fetch) . await ?;
120+ let ifd = ifd_reader. read ( fetch, extra_tags_registry ) . await ?;
120121 let next_ifd_offset = ifd_reader. finish ( fetch) . await ?;
121122 self . next_ifd_offset = next_ifd_offset;
122123 Ok ( Some ( ifd) )
@@ -129,9 +130,11 @@ impl TiffMetadataReader {
129130 pub async fn read_all_ifds < F : MetadataFetch > (
130131 & mut self ,
131132 fetch : & F ,
133+ extra_tags_registry : ExtraTagsRegistry ,
132134 ) -> AsyncTiffResult < Vec < ImageFileDirectory > > {
133135 let mut ifds = vec ! [ ] ;
134- while let Some ( ifd) = self . read_next_ifd ( fetch) . await ? {
136+ // deep clone the extra_tags_registry so we can have different values
137+ while let Some ( ifd) = self . read_next_ifd ( fetch, extra_tags_registry. deep_clone ( ) ) . await ? {
135138 ifds. push ( ifd) ;
136139 }
137140 Ok ( ifds)
@@ -158,8 +161,6 @@ pub struct ImageFileDirectoryReader {
158161 ifd_entry_byte_size : u64 ,
159162 /// The number of bytes that the value for the number of tags takes up.
160163 tag_count_byte_size : u64 ,
161- /// Registry for parsing extra tags
162- extra_tags_registry : ExtraTagsRegistry ,
163164}
164165
165166impl ImageFileDirectoryReader {
@@ -169,7 +170,6 @@ impl ImageFileDirectoryReader {
169170 ifd_start_offset : u64 ,
170171 bigtiff : bool ,
171172 endianness : Endianness ,
172- extra_tags_registry : ExtraTagsRegistry ,
173173 ) -> AsyncTiffResult < Self > {
174174 let mut cursor = MetadataCursor :: new_with_offset ( fetch, endianness, ifd_start_offset) ;
175175
@@ -198,7 +198,6 @@ impl ImageFileDirectoryReader {
198198 tag_count,
199199 tag_count_byte_size,
200200 ifd_start_offset,
201- extra_tags_registry,
202201 } )
203202 }
204203
@@ -225,13 +224,13 @@ impl ImageFileDirectoryReader {
225224 ///
226225 /// Keep in mind that you'll still need to call [`finish`][Self::finish] to get the byte offset
227226 /// of the next IFD.
228- pub async fn read < F : MetadataFetch > ( & self , fetch : & F ) -> AsyncTiffResult < ImageFileDirectory > {
227+ pub async fn read < F : MetadataFetch > ( & self , fetch : & F , extra_tags_registry : ExtraTagsRegistry ) -> AsyncTiffResult < ImageFileDirectory > {
229228 let mut tags = HashMap :: with_capacity ( self . tag_count as usize ) ;
230229 for tag_idx in 0 ..self . tag_count {
231230 let ( tag, value) = self . read_tag ( fetch, tag_idx) . await ?;
232231 tags. insert ( tag, value) ;
233232 }
234- ImageFileDirectory :: from_tags ( tags, self . endianness , self . extra_tags_registry )
233+ ImageFileDirectory :: from_tags ( tags, self . endianness , extra_tags_registry)
235234 }
236235
237236 /// Finish this reader, reading the byte offset of the next IFD
0 commit comments