1use super::exifreadable::*;
2use super::types::*;
3use std::borrow::Cow;
4
5type ReadableFn = fn(u16, &TagValue) -> Option<Cow<'static, str>>;
6
7pub(crate) fn tag_to_exif(f: u16) -> (ExifTag, &'static str, IfdFormat, i32, i32, ReadableFn) {
13 match f {
14 0x010e =>
15 (ExifTag::ImageDescription, "none", IfdFormat::Ascii,
16 -1i32, -1i32, strpass),
17
18 0x010f =>
19 (ExifTag::Make, "none", IfdFormat::Ascii, -1i32, -1i32, strpass),
20
21 0x013c =>
22 (ExifTag::HostComputer, "none", IfdFormat::Ascii, -1i32, -1i32, strpass),
23
24 0x0110 =>
25 (ExifTag::Model, "none", IfdFormat::Ascii, -1i32, -1i32, strpass),
26
27 0x0112 =>
28 (ExifTag::Orientation, "none", IfdFormat::U16, 1, 1, orientation),
29
30 0x011a =>
31 (ExifTag::XResolution, "pixels per res unit",
32 IfdFormat::URational, 1, 1, rational_value),
33
34 0x011b =>
35 (ExifTag::YResolution, "pixels per res unit",
36 IfdFormat::URational, 1, 1, rational_value),
37
38 0x0128 =>
39 (ExifTag::ResolutionUnit, "none", IfdFormat::U16, 1, 1, resolution_unit),
40
41 0x0131 =>
42 (ExifTag::Software, "none", IfdFormat::Ascii, -1i32, -1i32, strpass),
43
44 0x0132 =>
45 (ExifTag::DateTime, "none", IfdFormat::Ascii, -1i32, -1i32, strpass),
46
47 0x013e =>
48 (ExifTag::WhitePoint, "CIE 1931 coordinates",
49 IfdFormat::URational, 2, 2, rational_values),
50
51 0x013f =>
52 (ExifTag::PrimaryChromaticities, "CIE 1931 coordinates",
53 IfdFormat::URational, 6, 6, rational_values),
54
55 0x0211 =>
56 (ExifTag::YCbCrCoefficients, "none",
57 IfdFormat::URational, 3, 3, rational_values),
58
59 0x0214 =>
60 (ExifTag::ReferenceBlackWhite, "RGB or YCbCr",
61 IfdFormat::URational, 6, 6, rational_values),
62
63 0x8298 =>
64 (ExifTag::Copyright, "none", IfdFormat::Ascii, -1i32, -1i32, strpass),
65
66 0x8769 =>
67 (ExifTag::ExifOffset, "byte offset",
68 IfdFormat::U32, 1, 1, strpass),
69
70 0x8825 =>
71 (ExifTag::GPSOffset, "byte offset",
72 IfdFormat::U32, 1, 1, strpass),
73
74 0x829a =>
75 (ExifTag::ExposureTime, "s",
76 IfdFormat::URational, 1, 1, exposure_time),
77
78 0x829d =>
79 (ExifTag::FNumber, "f-number",
80 IfdFormat::URational, 1, 1, f_number),
81
82 0x8822 =>
83 (ExifTag::ExposureProgram, "none",
84 IfdFormat::U16, 1, 1, exposure_program),
85
86 0x8824 =>
87 (ExifTag::SpectralSensitivity, "ASTM string",
88 IfdFormat::Ascii, -1i32, -1i32, strpass),
89
90 0x8830 =>
91 (ExifTag::SensitivityType, "none",
92 IfdFormat::U16, 1, 1, sensitivity_type),
93
94 0x8827 =>
95 (ExifTag::ISOSpeedRatings, "ISO",
96 IfdFormat::U16, 1, 3, iso_speeds),
97
98 0x8828 =>
99 (ExifTag::OECF, "none",
100 IfdFormat::Undefined, -1i32, -1i32, undefined_as_blob),
101
102 0x9000 =>
103 (ExifTag::ExifVersion, "none",
104 IfdFormat::Undefined, -1i32, -1i32, undefined_as_ascii),
105
106 0x9003 =>
107 (ExifTag::DateTimeOriginal, "none",
108 IfdFormat::Ascii, -1i32, -1i32, strpass),
109
110 0x9004 =>
111 (ExifTag::DateTimeDigitized, "none",
112 IfdFormat::Ascii, -1i32, -1i32, strpass),
113
114 0x9201 =>
115 (ExifTag::ShutterSpeedValue, "APEX",
116 IfdFormat::IRational, 1, 1, apex_tv),
117
118 0x9202 =>
119 (ExifTag::ApertureValue, "APEX",
120 IfdFormat::URational, 1, 1, apex_av),
121
122 0x9203 =>
123 (ExifTag::BrightnessValue, "APEX",
124 IfdFormat::IRational, 1, 1, apex_brightness),
125
126 0x9204 =>
127 (ExifTag::ExposureBiasValue, "APEX",
128 IfdFormat::IRational, 1, 1, apex_ev),
129
130 0x9205 =>
131 (ExifTag::MaxApertureValue,
132 "APEX", IfdFormat::URational, 1, 1, apex_av),
133
134 0x9206 =>
135 (ExifTag::SubjectDistance, "m",
136 IfdFormat::URational, 1, 1, meters),
137
138 0x9207 =>
139 (ExifTag::MeteringMode, "none",
140 IfdFormat::U16, 1, 1, metering_mode),
141
142 0x9208 =>
143 (ExifTag::LightSource, "none",
144 IfdFormat::U16, 1, 1, light_source),
145
146 0x9209 => (ExifTag::Flash, "none",
147 IfdFormat::U16, 1, 2, flash),
148
149 0x920a =>
150 (ExifTag::FocalLength, "mm",
151 IfdFormat::URational, 1, 1, focal_length),
152
153 0x9214 =>
154 (ExifTag::SubjectArea, "px",
155 IfdFormat::U16, 2, 4, subject_area),
156
157 0x927c =>
158 (ExifTag::MakerNote, "none",
159 IfdFormat::Undefined, -1i32, -1i32, undefined_as_blob),
160
161 0x9286 =>
162 (ExifTag::UserComment, "none",
163 IfdFormat::Undefined, -1i32, -1i32, undefined_as_encoded_string),
164
165 0xa000 =>
166 (ExifTag::FlashPixVersion, "none",
167 IfdFormat::Undefined, -1i32, -1i32, undefined_as_ascii),
168
169 0xa001 =>
170 (ExifTag::ColorSpace, "none",
171 IfdFormat::U16, 1, 1, color_space),
172
173 0xa004 =>
174 (ExifTag::RelatedSoundFile, "none",
175 IfdFormat::Ascii, -1i32, -1i32, strpass),
176
177 0xa20b => (ExifTag::FlashEnergy, "BCPS",
178 IfdFormat::URational, 1, 1, flash_energy),
179
180 0xa20e =>
181 (ExifTag::FocalPlaneXResolution, "@FocalPlaneResolutionUnit",
182 IfdFormat::URational, 1, 1, rational_value),
183
184 0xa20f =>
185 (ExifTag::FocalPlaneYResolution, "@FocalPlaneResolutionUnit",
186 IfdFormat::URational, 1, 1, rational_value),
187
188 0xa210 =>
189 (ExifTag::FocalPlaneResolutionUnit, "none",
190 IfdFormat::U16, 1, 1, resolution_unit),
191
192 0xa214 =>
193 (ExifTag::SubjectLocation, "X,Y",
194 IfdFormat::U16, 2, 2, subject_location),
195
196 0xa215 =>
198 (ExifTag::ExposureIndex, "EI",
199 IfdFormat::URational, 1, 1, rational_value),
200
201 0xa217 =>
202 (ExifTag::SensingMethod, "none",
203 IfdFormat::U16, 1, 1, sensing_method),
204
205 0xa300 =>
206 (ExifTag::FileSource, "none",
207 IfdFormat::Undefined, 1, 1, file_source),
208
209 0xa301 =>
210 (ExifTag::SceneType, "none",
211 IfdFormat::Undefined, 1, 1, scene_type),
212
213 0xa302 =>
214 (ExifTag::CFAPattern, "none",
215 IfdFormat::Undefined, -1i32, -1i32, undefined_as_u8),
216
217 0xa401 =>
218 (ExifTag::CustomRendered, "none",
219 IfdFormat::U16, 1, 1, custom_rendered),
220
221 0xa402 =>
222 (ExifTag::ExposureMode, "none",
223 IfdFormat::U16, 1, 1, exposure_mode),
224
225 0xa403 =>
226 (ExifTag::WhiteBalanceMode, "none",
227 IfdFormat::U16, 1, 1, white_balance_mode),
228
229 0xa404 =>
230 (ExifTag::DigitalZoomRatio, "none",
231 IfdFormat::URational, 1, 1, rational_value),
232
233 0xa405 =>
234 (ExifTag::FocalLengthIn35mmFilm, "mm",
235 IfdFormat::U16, 1, 1, focal_length_35),
236
237 0xa406 =>
238 (ExifTag::SceneCaptureType, "none",
239 IfdFormat::U16, 1, 1, scene_capture_type),
240
241 0xa407 =>
242 (ExifTag::GainControl, "none",
243 IfdFormat::U16, 1, 1, gain_control),
244
245 0xa408 =>
246 (ExifTag::Contrast, "none",
247 IfdFormat::U16, 1, 1, contrast),
248
249 0xa409 =>
250 (ExifTag::Saturation, "none",
251 IfdFormat::U16, 1, 1, saturation),
252
253 0xa40a =>
254 (ExifTag::Sharpness, "none",
255 IfdFormat::U16, 1, 1, sharpness),
256
257 0xa432 =>
258 (ExifTag::LensSpecification, "none",
259 IfdFormat::URational, 4, 4, lens_spec),
260
261 0xa433 =>
262 (ExifTag::LensMake, "none",
263 IfdFormat::Ascii, -1i32, -1i32, strpass),
264
265 0xa434 =>
266 (ExifTag::LensModel, "none",
267 IfdFormat::Ascii, -1i32, -1i32, strpass),
268
269 0xa500 =>
270 (ExifTag::Gamma, "none",
271 IfdFormat::URational, 1, 1, rational_value),
272
273 0xa40b =>
275 (ExifTag::DeviceSettingDescription, "none",
276 IfdFormat::Undefined, -1i32, -1i32, undefined_as_blob),
277
278 0xa40c =>
279 (ExifTag::SubjectDistanceRange, "none",
280 IfdFormat::U16, 1, 1, subject_distance_range),
281
282 0xa420 =>
283 (ExifTag::ImageUniqueID, "none",
284 IfdFormat::Ascii, -1i32, -1i32, strpass),
285
286 0x0 =>
287 (ExifTag::GPSVersionID, "none",
288 IfdFormat::U8, 4, 4, strpass),
289
290 0x1 =>
291 (ExifTag::GPSLatitudeRef, "none",
292 IfdFormat::Ascii, -1i32, -1i32, strpass),
293
294 0x2 =>
295 (ExifTag::GPSLatitude, "D/M/S",
296 IfdFormat::URational, 3, 3, dms),
297
298 0x3 =>
299 (ExifTag::GPSLongitudeRef, "none",
300 IfdFormat::Ascii, -1i32, -1i32, strpass),
301
302 0x4 =>
303 (ExifTag::GPSLongitude, "D/M/S",
304 IfdFormat::URational, 3, 3, dms),
305
306 0x5 =>
307 (ExifTag::GPSAltitudeRef, "none",
308 IfdFormat::U8, 1, 1, gps_alt_ref),
309
310 0x6 =>
311 (ExifTag::GPSAltitude, "m",
312 IfdFormat::URational, 1, 1, meters),
313
314 0x7 =>
315 (ExifTag::GPSTimeStamp, "UTC time",
316 IfdFormat::URational, 3, 3, gpstimestamp),
317
318 0x8 => (ExifTag::GPSSatellites, "none",
319 IfdFormat::Ascii, -1i32, -1i32, strpass),
320
321 0x9 => (ExifTag::GPSStatus, "none",
322 IfdFormat::Ascii, -1i32, -1i32, gpsstatus),
323
324 0xa => (ExifTag::GPSMeasureMode, "none",
325 IfdFormat::Ascii, -1i32, -1i32, gpsmeasuremode),
326
327 0xb =>
328 (ExifTag::GPSDOP, "none",
329 IfdFormat::URational, 1, 1, rational_value),
330
331 0xc =>
332 (ExifTag::GPSSpeedRef, "none",
333 IfdFormat::Ascii, -1i32, -1i32, gpsspeedref),
334
335 0xd =>
336 (ExifTag::GPSSpeed, "@GPSSpeedRef",
337 IfdFormat::URational, 1, 1, gpsspeed),
338
339 0xe =>
340 (ExifTag::GPSTrackRef, "none",
341 IfdFormat::Ascii, -1i32, -1i32, gpsbearingref),
342
343 0xf =>
344 (ExifTag::GPSTrack, "deg",
345 IfdFormat::URational, 1, 1, gpsbearing),
346
347 0x10 =>
348 (ExifTag::GPSImgDirectionRef, "none",
349 IfdFormat::Ascii, -1i32, -1i32, gpsbearingref),
350
351 0x11 =>
352 (ExifTag::GPSImgDirection, "deg",
353 IfdFormat::URational, 1, 1, gpsbearing),
354
355 0x12 =>
356 (ExifTag::GPSMapDatum, "none",
357 IfdFormat::Ascii, -1i32, -1i32, strpass),
358
359 0x13 =>
360 (ExifTag::GPSDestLatitudeRef, "none",
361 IfdFormat::Ascii, -1i32, -1i32, strpass),
362
363 0x14 =>
364 (ExifTag::GPSDestLatitude, "D/M/S",
365 IfdFormat::URational, 3, 3, dms),
366
367 0x15 =>
368 (ExifTag::GPSDestLongitudeRef, "none",
369 IfdFormat::Ascii, -1i32, -1i32, strpass),
370
371 0x16 =>
372 (ExifTag::GPSDestLongitude, "D/M/S",
373 IfdFormat::URational, 3, 3, dms),
374
375 0x17 =>
376 (ExifTag::GPSDestBearingRef, "none",
377 IfdFormat::Ascii, -1i32, -1i32, gpsbearingref),
378
379 0x18 =>
380 (ExifTag::GPSDestBearing, "deg",
381 IfdFormat::URational, 1, 1, gpsbearing),
382
383 0x19 =>
384 (ExifTag::GPSDestDistanceRef, "none",
385 IfdFormat::Ascii, -1i32, -1i32, gpsdestdistanceref),
386
387 0x1a =>
388 (ExifTag::GPSDestDistance, "@GPSDestDistanceRef",
389 IfdFormat::URational, 1, 1, gpsdestdistance),
390
391 0x1b =>
392 (ExifTag::GPSProcessingMethod, "none",
393 IfdFormat::Undefined, -1i32, -1i32, undefined_as_encoded_string),
394
395 0x1c => (ExifTag::GPSAreaInformation,
396 "none", IfdFormat::Undefined, -1i32, -1i32, undefined_as_encoded_string),
397
398 0x1d =>
399 (ExifTag::GPSDateStamp, "none",
400 IfdFormat::Ascii, -1i32, -1i32, strpass),
401
402 0x1e =>
403 (ExifTag::GPSDifferential, "none",
404 IfdFormat::U16, 1, 1, gpsdiff),
405
406 _ =>
407 (ExifTag::UnknownToMe, "Unknown unit",
408 IfdFormat::Unknown, -1i32, -1i32, unknown)
409 }
410}