@@ -839,7 +839,6 @@ impl ImageFileDirectory {
839839
840840/// Read a single tag from the cursor
841841async fn read_tag ( cursor : & mut AsyncCursor , bigtiff : bool ) -> AsyncTiffResult < ( Tag , Value ) > {
842- // let start_cursor_position = cursor.position();
843842
844843 let tag_name = Tag :: from_u16_exhaustive ( cursor. read_u16 ( ) . await ?) ;
845844
@@ -855,10 +854,6 @@ async fn read_tag(cursor: &mut AsyncCursor, bigtiff: bool) -> AsyncTiffResult<(T
855854
856855 let tag_value = read_tag_value ( cursor, tag_type, count, bigtiff) . await ?;
857856
858- // TODO: better handle management of cursor state <- should be done now
859- // let ifd_entry_size = if bigtiff { 20 } else { 12 };
860- // cursor.seek(start_cursor_position + ifd_entry_size);
861-
862857 Ok ( ( tag_name, tag_value) )
863858}
864859
@@ -878,7 +873,18 @@ async fn read_tag_value(
878873 return Ok ( Value :: List ( vec ! [ ] ) ) ;
879874 }
880875
881- let tag_size = tag_type. size ( ) ;
876+ let tag_size =
877+ match tag_type {
878+ Type :: BYTE | Type :: SBYTE | Type :: ASCII | Type :: UNDEFINED => 1 ,
879+ Type :: SHORT | Type :: SSHORT => 2 ,
880+ Type :: LONG | Type :: SLONG | Type :: FLOAT | Type :: IFD => 4 ,
881+ Type :: LONG8
882+ | Type :: SLONG8
883+ | Type :: DOUBLE
884+ | Type :: RATIONAL
885+ | Type :: SRATIONAL
886+ | Type :: IFD8 => 8 ,
887+ } ;
882888
883889 let value_byte_length = count. checked_mul ( tag_size) . unwrap ( ) ;
884890
@@ -901,12 +907,10 @@ async fn read_tag_value(
901907 } ;
902908 let reader = cursor
903909 . reader ( )
904- . get_bytes ( offset..offset + value_byte_length)
910+ . get_metadata_bytes ( offset..offset + value_byte_length)
905911 . await ?
906912 . reader ( ) ;
907913 EndianAwareReader :: new ( reader, cursor. endianness ( ) )
908- // cursor.seek(offset);
909- // cursor.read(value_byte_length).await?
910914 } ;
911915 // Case 2: there is one value.
912916 if count == 1 {
0 commit comments