@@ -36,6 +36,47 @@ fn encode_decode() {
36
36
let mut decoder = Decoder :: new ( & mut file) . unwrap ( ) ;
37
37
assert_eq ! ( decoder. colortype( ) . unwrap( ) , ColorType :: RGB ( 8 ) ) ;
38
38
assert_eq ! ( decoder. dimensions( ) . unwrap( ) , ( 100 , 100 ) ) ;
39
+
40
+ let mut all_tags = decoder
41
+ . tag_iter ( )
42
+ . filter_map ( Result :: ok)
43
+ . collect :: < Vec < _ > > ( ) ;
44
+ all_tags. sort_by_key ( |( t, _) | t. to_u16 ( ) ) ;
45
+ assert_eq ! (
46
+ all_tags,
47
+ vec![
48
+ ( Tag :: ImageWidth , ifd:: Value :: Unsigned ( 100 ) ) ,
49
+ ( Tag :: ImageLength , ifd:: Value :: Unsigned ( 100 ) ) ,
50
+ (
51
+ Tag :: BitsPerSample ,
52
+ ifd:: Value :: List ( vec![
53
+ ifd:: Value :: UnsignedBig ( 8 ) ,
54
+ ifd:: Value :: UnsignedBig ( 8 ) ,
55
+ ifd:: Value :: UnsignedBig ( 8 )
56
+ ] )
57
+ ) ,
58
+ ( Tag :: Compression , ifd:: Value :: Unsigned ( 1 ) ) ,
59
+ ( Tag :: PhotometricInterpretation , ifd:: Value :: Unsigned ( 2 ) ) ,
60
+ ( Tag :: StripOffsets , ifd:: Value :: Unsigned ( 8 ) ) ,
61
+ ( Tag :: SamplesPerPixel , ifd:: Value :: Unsigned ( 3 ) ) ,
62
+ ( Tag :: RowsPerStrip , ifd:: Value :: Unsigned ( 3334 ) ) ,
63
+ ( Tag :: StripByteCounts , ifd:: Value :: Unsigned ( 30000 ) ) ,
64
+ ( Tag :: XResolution , ifd:: Value :: Rational ( 1 , 1 ) ) ,
65
+ ( Tag :: YResolution , ifd:: Value :: Rational ( 1 , 1 ) ) ,
66
+ ( Tag :: ResolutionUnit , ifd:: Value :: Unsigned ( 1 ) ) ,
67
+ ( Tag :: Artist , ifd:: Value :: Ascii ( "Image-tiff" . into( ) ) ) ,
68
+ ( Tag :: Predictor , ifd:: Value :: Unsigned ( 1 ) ) ,
69
+ (
70
+ Tag :: SampleFormat ,
71
+ ifd:: Value :: List ( vec![
72
+ ifd:: Value :: UnsignedBig ( 1 ) ,
73
+ ifd:: Value :: UnsignedBig ( 1 ) ,
74
+ ifd:: Value :: UnsignedBig ( 1 )
75
+ ] )
76
+ ) ,
77
+ ]
78
+ ) ;
79
+
39
80
assert_eq ! (
40
81
decoder. get_tag( Tag :: Artist ) . unwrap( ) ,
41
82
ifd:: Value :: Ascii ( "Image-tiff" . into( ) )
@@ -75,6 +116,47 @@ fn encode_decode_big() {
75
116
let mut decoder = Decoder :: new ( & mut file) . unwrap ( ) ;
76
117
assert_eq ! ( decoder. colortype( ) . unwrap( ) , ColorType :: RGB ( 8 ) ) ;
77
118
assert_eq ! ( decoder. dimensions( ) . unwrap( ) , ( 100 , 100 ) ) ;
119
+
120
+ let mut all_tags = decoder
121
+ . tag_iter ( )
122
+ . filter_map ( Result :: ok)
123
+ . collect :: < Vec < _ > > ( ) ;
124
+ all_tags. sort_by_key ( |( t, _) | t. to_u16 ( ) ) ;
125
+ assert_eq ! (
126
+ all_tags,
127
+ vec![
128
+ ( Tag :: ImageWidth , ifd:: Value :: Unsigned ( 100 ) ) ,
129
+ ( Tag :: ImageLength , ifd:: Value :: Unsigned ( 100 ) ) ,
130
+ (
131
+ Tag :: BitsPerSample ,
132
+ ifd:: Value :: List ( vec![
133
+ ifd:: Value :: Short ( 8 ) ,
134
+ ifd:: Value :: Short ( 8 ) ,
135
+ ifd:: Value :: Short ( 8 )
136
+ ] )
137
+ ) ,
138
+ ( Tag :: Compression , ifd:: Value :: Unsigned ( 1 ) ) ,
139
+ ( Tag :: PhotometricInterpretation , ifd:: Value :: Unsigned ( 2 ) ) ,
140
+ ( Tag :: StripOffsets , ifd:: Value :: UnsignedBig ( 16 ) ) ,
141
+ ( Tag :: SamplesPerPixel , ifd:: Value :: Unsigned ( 3 ) ) ,
142
+ ( Tag :: RowsPerStrip , ifd:: Value :: Unsigned ( 3334 ) ) ,
143
+ ( Tag :: StripByteCounts , ifd:: Value :: UnsignedBig ( 30000 ) ) ,
144
+ ( Tag :: XResolution , ifd:: Value :: Rational ( 1 , 1 ) ) ,
145
+ ( Tag :: YResolution , ifd:: Value :: Rational ( 1 , 1 ) ) ,
146
+ ( Tag :: ResolutionUnit , ifd:: Value :: Unsigned ( 1 ) ) ,
147
+ ( Tag :: Artist , ifd:: Value :: Ascii ( "Image-tiff" . into( ) ) ) ,
148
+ ( Tag :: Predictor , ifd:: Value :: Unsigned ( 1 ) ) ,
149
+ (
150
+ Tag :: SampleFormat ,
151
+ ifd:: Value :: List ( vec![
152
+ ifd:: Value :: Short ( 1 ) ,
153
+ ifd:: Value :: Short ( 1 ) ,
154
+ ifd:: Value :: Short ( 1 )
155
+ ] )
156
+ ) ,
157
+ ]
158
+ ) ;
159
+
78
160
assert_eq ! (
79
161
decoder. get_tag( Tag :: Artist ) . unwrap( ) ,
80
162
ifd:: Value :: Ascii ( "Image-tiff" . into( ) )
0 commit comments