source: josm/trunk/src/com/drew/metadata/exif/makernotes/OlympusEquipmentMakernoteDescriptor.java@ 12187

Last change on this file since 12187 was 10862, checked in by Don-vip, 8 years ago

update to metadata-extractor 2.9.1

  • Property svn:eol-style set to native
File size: 17.5 KB
Line 
1/*
2 * Copyright 2002-2015 Drew Noakes
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * More information about this project is available at:
17 *
18 * https://drewnoakes.com/code/exif/
19 * https://github.com/drewnoakes/metadata-extractor
20 */
21package com.drew.metadata.exif.makernotes;
22
23import com.drew.lang.annotations.NotNull;
24import com.drew.lang.annotations.Nullable;
25import com.drew.metadata.TagDescriptor;
26
27import java.text.DecimalFormat;
28import java.util.HashMap;
29
30import static com.drew.metadata.exif.makernotes.OlympusEquipmentMakernoteDirectory.*;
31
32/**
33 * Provides human-readable String representations of tag values stored in a {@link OlympusEquipmentMakernoteDirectory}.
34 * <p>
35 * Some Description functions and the Extender and Lens types lists converted from Exiftool version 10.10 created by Phil Harvey
36 * http://www.sno.phy.queensu.ca/~phil/exiftool/
37 * lib\Image\ExifTool\Olympus.pm
38 *
39 * @author Kevin Mott https://github.com/kwhopper
40 * @author Drew Noakes https://drewnoakes.com
41 */
42public class OlympusEquipmentMakernoteDescriptor extends TagDescriptor<OlympusEquipmentMakernoteDirectory>
43{
44 public OlympusEquipmentMakernoteDescriptor(@NotNull OlympusEquipmentMakernoteDirectory directory)
45 {
46 super(directory);
47 }
48
49 @Override
50 @Nullable
51 public String getDescription(int tagType)
52 {
53 switch (tagType) {
54 case TAG_EQUIPMENT_VERSION:
55 return GetEquipmentVersionDescription();
56 case TAG_FOCAL_PLANE_DIAGONAL:
57 return GetFocalPlaneDiagonalDescription();
58 case TAG_BODY_FIRMWARE_VERSION:
59 return GetBodyFirmwareVersionDescription();
60 case TAG_LENS_TYPE:
61 return GetLensTypeDescription();
62 case TAG_LENS_FIRMWARE_VERSION:
63 return GetLensFirmwareVersionDescription();
64 case TAG_MAX_APERTURE_AT_MIN_FOCAL:
65 return GetMaxApertureAtMinFocalDescription();
66 case TAG_MAX_APERTURE_AT_MAX_FOCAL:
67 return GetMaxApertureAtMaxFocalDescription();
68 case TAG_MAX_APERTURE:
69 return GetMaxApertureDescription();
70 case TAG_LENS_PROPERTIES:
71 return GetLensPropertiesDescription();
72 case TAG_EXTENDER:
73 return GetExtenderDescription();
74 case TAG_FLASH_TYPE:
75 return GetFlashTypeDescription();
76 case TAG_FLASH_MODEL:
77 return GetFlashModelDescription();
78 default:
79 return super.getDescription(tagType);
80 }
81 }
82
83 @Nullable
84 public String GetEquipmentVersionDescription()
85 {
86 return getVersionBytesDescription(TAG_EQUIPMENT_VERSION, 4);
87 }
88
89 @Nullable
90 public String GetFocalPlaneDiagonalDescription()
91 {
92 return _directory.getString(TAG_FOCAL_PLANE_DIAGONAL) + " mm";
93 }
94
95 @Nullable
96 public String GetBodyFirmwareVersionDescription()
97 {
98 Integer value = _directory.getInteger(TAG_BODY_FIRMWARE_VERSION);
99 if (value == null)
100 return null;
101
102 String hex = String.format("%04X", value);
103 return String.format("%s.%s",
104 hex.substring(0, hex.length() - 3),
105 hex.substring(hex.length() - 3));
106 }
107
108 @Nullable
109 public String GetLensTypeDescription()
110 {
111 String str = _directory.getString(TAG_LENS_TYPE);
112
113 if (str == null)
114 return null;
115
116 // The String contains six numbers:
117 //
118 // - Make
119 // - Unknown
120 // - Model
121 // - Sub-model
122 // - Unknown
123 // - Unknown
124 //
125 // Only the Make, Model and Sub-model are used to identify the lens type
126 String[] values = str.split(" ");
127
128 if (values.length < 6)
129 return null;
130
131 try {
132 int num1 = Integer.parseInt(values[0]);
133 int num2 = Integer.parseInt(values[2]);
134 int num3 = Integer.parseInt(values[3]);
135 return _olympusLensTypes.get(String.format("%X %02X %02X", num1, num2, num3));
136 } catch (NumberFormatException e) {
137 return null;
138 }
139 }
140
141 @Nullable
142 public String GetLensFirmwareVersionDescription()
143 {
144 Integer value = _directory.getInteger(TAG_LENS_FIRMWARE_VERSION);
145 if (value == null)
146 return null;
147
148 String hex = String.format("%04X", value);
149 return String.format("%s.%s",
150 hex.substring(0, hex.length() - 3),
151 hex.substring(hex.length() - 3));
152 }
153
154 @Nullable
155 public String GetMaxApertureAtMinFocalDescription()
156 {
157 Integer value = _directory.getInteger(TAG_MAX_APERTURE_AT_MIN_FOCAL);
158 if (value == null)
159 return null;
160
161 DecimalFormat format = new DecimalFormat("0.#");
162 return format.format(CalcMaxAperture(value));
163 }
164
165 @Nullable
166 public String GetMaxApertureAtMaxFocalDescription()
167 {
168 Integer value = _directory.getInteger(TAG_MAX_APERTURE_AT_MAX_FOCAL);
169 if (value == null)
170 return null;
171
172 DecimalFormat format = new DecimalFormat("0.#");
173 return format.format(CalcMaxAperture(value));
174 }
175
176 @Nullable
177 public String GetMaxApertureDescription()
178 {
179 Integer value = _directory.getInteger(TAG_MAX_APERTURE);
180 if (value == null)
181 return null;
182
183 DecimalFormat format = new DecimalFormat("0.#");
184 return format.format(CalcMaxAperture(value));
185 }
186
187 private static double CalcMaxAperture(int value)
188 {
189 return Math.pow(Math.sqrt(2.00), value / 256.0);
190 }
191
192 @Nullable
193 public String GetLensPropertiesDescription()
194 {
195 Integer value = _directory.getInteger(TAG_LENS_PROPERTIES);
196 if (value == null)
197 return null;
198
199 return String.format("0x%04X", value);
200 }
201
202 @Nullable
203 public String GetExtenderDescription()
204 {
205 String str = _directory.getString(TAG_EXTENDER);
206
207 if (str == null)
208 return null;
209
210 // The String contains six numbers:
211 //
212 // - Make
213 // - Unknown
214 // - Model
215 // - Sub-model
216 // - Unknown
217 // - Unknown
218 //
219 // Only the Make and Model are used to identify the extender
220 String[] values = str.split(" ");
221
222 if (values.length < 6)
223 return null;
224
225 try {
226 int num1 = Integer.parseInt(values[0]);
227 int num2 = Integer.parseInt(values[2]);
228 String extenderType = String.format("%X %02X", num1, num2);
229 return _olympusExtenderTypes.get(extenderType);
230 } catch (NumberFormatException e) {
231 return null;
232 }
233 }
234
235 @Nullable
236 public String GetFlashTypeDescription()
237 {
238 return getIndexedDescription(TAG_FLASH_TYPE,
239 "None", null, "Simple E-System", "E-System");
240 }
241
242 @Nullable
243 public String GetFlashModelDescription()
244 {
245 return getIndexedDescription(TAG_FLASH_MODEL,
246 "None", "FL-20", "FL-50", "RF-11", "TF-22", "FL-36", "FL-50R", "FL-36R");
247 }
248
249 private static final HashMap<String, String> _olympusLensTypes = new HashMap<String, String>();
250 private static final HashMap<String, String> _olympusExtenderTypes = new HashMap<String, String>();
251
252 static {
253 _olympusLensTypes.put("0 00 00", "None");
254 // Olympus lenses (also Kenko Tokina)
255 _olympusLensTypes.put("0 01 00", "Olympus Zuiko Digital ED 50mm F2.0 Macro");
256 _olympusLensTypes.put("0 01 01", "Olympus Zuiko Digital 40-150mm F3.5-4.5"); //8
257 _olympusLensTypes.put("0 01 10", "Olympus M.Zuiko Digital ED 14-42mm F3.5-5.6"); //PH (E-P1 pre-production)
258 _olympusLensTypes.put("0 02 00", "Olympus Zuiko Digital ED 150mm F2.0");
259 _olympusLensTypes.put("0 02 10", "Olympus M.Zuiko Digital 17mm F2.8 Pancake"); //PH (E-P1 pre-production)
260 _olympusLensTypes.put("0 03 00", "Olympus Zuiko Digital ED 300mm F2.8");
261 _olympusLensTypes.put("0 03 10", "Olympus M.Zuiko Digital ED 14-150mm F4.0-5.6 [II]"); //11 (The second version of this lens seems to have the same lens ID number as the first version #20)
262 _olympusLensTypes.put("0 04 10", "Olympus M.Zuiko Digital ED 9-18mm F4.0-5.6"); //11
263 _olympusLensTypes.put("0 05 00", "Olympus Zuiko Digital 14-54mm F2.8-3.5");
264 _olympusLensTypes.put("0 05 01", "Olympus Zuiko Digital Pro ED 90-250mm F2.8"); //9
265 _olympusLensTypes.put("0 05 10", "Olympus M.Zuiko Digital ED 14-42mm F3.5-5.6 L"); //11 (E-PL1)
266 _olympusLensTypes.put("0 06 00", "Olympus Zuiko Digital ED 50-200mm F2.8-3.5");
267 _olympusLensTypes.put("0 06 01", "Olympus Zuiko Digital ED 8mm F3.5 Fisheye"); //9
268 _olympusLensTypes.put("0 06 10", "Olympus M.Zuiko Digital ED 40-150mm F4.0-5.6"); //PH
269 _olympusLensTypes.put("0 07 00", "Olympus Zuiko Digital 11-22mm F2.8-3.5");
270 _olympusLensTypes.put("0 07 01", "Olympus Zuiko Digital 18-180mm F3.5-6.3"); //6
271 _olympusLensTypes.put("0 07 10", "Olympus M.Zuiko Digital ED 12mm F2.0"); //PH
272 _olympusLensTypes.put("0 08 01", "Olympus Zuiko Digital 70-300mm F4.0-5.6"); //7 (seen as release 1 - PH)
273 _olympusLensTypes.put("0 08 10", "Olympus M.Zuiko Digital ED 75-300mm F4.8-6.7"); //PH
274 _olympusLensTypes.put("0 09 10", "Olympus M.Zuiko Digital 14-42mm F3.5-5.6 II"); //PH (E-PL2)
275 _olympusLensTypes.put("0 10 01", "Kenko Tokina Reflex 300mm F6.3 MF Macro"); //20
276 _olympusLensTypes.put("0 10 10", "Olympus M.Zuiko Digital ED 12-50mm F3.5-6.3 EZ"); //PH
277 _olympusLensTypes.put("0 11 10", "Olympus M.Zuiko Digital 45mm F1.8"); //17
278 _olympusLensTypes.put("0 12 10", "Olympus M.Zuiko Digital ED 60mm F2.8 Macro"); //20
279 _olympusLensTypes.put("0 13 10", "Olympus M.Zuiko Digital 14-42mm F3.5-5.6 II R"); //PH/20
280 _olympusLensTypes.put("0 14 10", "Olympus M.Zuiko Digital ED 40-150mm F4.0-5.6 R"); //19
281 // '0 14 10.1", "Olympus M.Zuiko Digital ED 14-150mm F4.0-5.6 II"); //11 (questionable & unconfirmed -- all samples I can find are '0 3 10' - PH)
282 _olympusLensTypes.put("0 15 00", "Olympus Zuiko Digital ED 7-14mm F4.0");
283 _olympusLensTypes.put("0 15 10", "Olympus M.Zuiko Digital ED 75mm F1.8"); //PH
284 _olympusLensTypes.put("0 16 10", "Olympus M.Zuiko Digital 17mm F1.8"); //20
285 _olympusLensTypes.put("0 17 00", "Olympus Zuiko Digital Pro ED 35-100mm F2.0"); //7
286 _olympusLensTypes.put("0 18 00", "Olympus Zuiko Digital 14-45mm F3.5-5.6");
287 _olympusLensTypes.put("0 18 10", "Olympus M.Zuiko Digital ED 75-300mm F4.8-6.7 II"); //20
288 _olympusLensTypes.put("0 19 10", "Olympus M.Zuiko Digital ED 12-40mm F2.8 Pro"); //PH
289 _olympusLensTypes.put("0 20 00", "Olympus Zuiko Digital 35mm F3.5 Macro"); //9
290 _olympusLensTypes.put("0 20 10", "Olympus M.Zuiko Digital ED 40-150mm F2.8 Pro"); //20
291 _olympusLensTypes.put("0 21 10", "Olympus M.Zuiko Digital ED 14-42mm F3.5-5.6 EZ"); //20
292 _olympusLensTypes.put("0 22 00", "Olympus Zuiko Digital 17.5-45mm F3.5-5.6"); //9
293 _olympusLensTypes.put("0 22 10", "Olympus M.Zuiko Digital 25mm F1.8"); //20
294 _olympusLensTypes.put("0 23 00", "Olympus Zuiko Digital ED 14-42mm F3.5-5.6"); //PH
295 _olympusLensTypes.put("0 23 10", "Olympus M.Zuiko Digital ED 7-14mm F2.8 Pro"); //20
296 _olympusLensTypes.put("0 24 00", "Olympus Zuiko Digital ED 40-150mm F4.0-5.6"); //PH
297 _olympusLensTypes.put("0 24 10", "Olympus M.Zuiko Digital ED 300mm F4.0 IS Pro"); //20
298 _olympusLensTypes.put("0 25 10", "Olympus M.Zuiko Digital ED 8mm F1.8 Fisheye Pro"); //20
299 _olympusLensTypes.put("0 30 00", "Olympus Zuiko Digital ED 50-200mm F2.8-3.5 SWD"); //7
300 _olympusLensTypes.put("0 31 00", "Olympus Zuiko Digital ED 12-60mm F2.8-4.0 SWD"); //7
301 _olympusLensTypes.put("0 32 00", "Olympus Zuiko Digital ED 14-35mm F2.0 SWD"); //PH
302 _olympusLensTypes.put("0 33 00", "Olympus Zuiko Digital 25mm F2.8"); //PH
303 _olympusLensTypes.put("0 34 00", "Olympus Zuiko Digital ED 9-18mm F4.0-5.6"); //7
304 _olympusLensTypes.put("0 35 00", "Olympus Zuiko Digital 14-54mm F2.8-3.5 II"); //PH
305 // Sigma lenses
306 _olympusLensTypes.put("1 01 00", "Sigma 18-50mm F3.5-5.6 DC"); //8
307 _olympusLensTypes.put("1 01 10", "Sigma 30mm F2.8 EX DN"); //20
308 _olympusLensTypes.put("1 02 00", "Sigma 55-200mm F4.0-5.6 DC");
309 _olympusLensTypes.put("1 02 10", "Sigma 19mm F2.8 EX DN"); //20
310 _olympusLensTypes.put("1 03 00", "Sigma 18-125mm F3.5-5.6 DC");
311 _olympusLensTypes.put("1 03 10", "Sigma 30mm F2.8 DN | A"); //20
312 _olympusLensTypes.put("1 04 00", "Sigma 18-125mm F3.5-5.6 DC"); //7
313 _olympusLensTypes.put("1 04 10", "Sigma 19mm F2.8 DN | A"); //20
314 _olympusLensTypes.put("1 05 00", "Sigma 30mm F1.4 EX DC HSM"); //10
315 _olympusLensTypes.put("1 05 10", "Sigma 60mm F2.8 DN | A"); //20
316 _olympusLensTypes.put("1 06 00", "Sigma APO 50-500mm F4.0-6.3 EX DG HSM"); //6
317 _olympusLensTypes.put("1 07 00", "Sigma Macro 105mm F2.8 EX DG"); //PH
318 _olympusLensTypes.put("1 08 00", "Sigma APO Macro 150mm F2.8 EX DG HSM"); //PH
319 _olympusLensTypes.put("1 09 00", "Sigma 18-50mm F2.8 EX DC Macro"); //20
320 _olympusLensTypes.put("1 10 00", "Sigma 24mm F1.8 EX DG Aspherical Macro"); //PH
321 _olympusLensTypes.put("1 11 00", "Sigma APO 135-400mm F4.5-5.6 DG"); //11
322 _olympusLensTypes.put("1 12 00", "Sigma APO 300-800mm F5.6 EX DG HSM"); //11
323 _olympusLensTypes.put("1 13 00", "Sigma 30mm F1.4 EX DC HSM"); //11
324 _olympusLensTypes.put("1 14 00", "Sigma APO 50-500mm F4.0-6.3 EX DG HSM"); //11
325 _olympusLensTypes.put("1 15 00", "Sigma 10-20mm F4.0-5.6 EX DC HSM"); //11
326 _olympusLensTypes.put("1 16 00", "Sigma APO 70-200mm F2.8 II EX DG Macro HSM"); //11
327 _olympusLensTypes.put("1 17 00", "Sigma 50mm F1.4 EX DG HSM"); //11
328 // Panasonic/Leica lenses
329 _olympusLensTypes.put("2 01 00", "Leica D Vario Elmarit 14-50mm F2.8-3.5 Asph."); //11
330 _olympusLensTypes.put("2 01 10", "Lumix G Vario 14-45mm F3.5-5.6 Asph. Mega OIS"); //16
331 _olympusLensTypes.put("2 02 00", "Leica D Summilux 25mm F1.4 Asph."); //11
332 _olympusLensTypes.put("2 02 10", "Lumix G Vario 45-200mm F4.0-5.6 Mega OIS"); //16
333 _olympusLensTypes.put("2 03 00", "Leica D Vario Elmar 14-50mm F3.8-5.6 Asph. Mega OIS"); //11
334 _olympusLensTypes.put("2 03 01", "Leica D Vario Elmar 14-50mm F3.8-5.6 Asph."); //14 (L10 kit)
335 _olympusLensTypes.put("2 03 10", "Lumix G Vario HD 14-140mm F4.0-5.8 Asph. Mega OIS"); //16
336 _olympusLensTypes.put("2 04 00", "Leica D Vario Elmar 14-150mm F3.5-5.6"); //13
337 _olympusLensTypes.put("2 04 10", "Lumix G Vario 7-14mm F4.0 Asph."); //PH (E-P1 pre-production)
338 _olympusLensTypes.put("2 05 10", "Lumix G 20mm F1.7 Asph."); //16
339 _olympusLensTypes.put("2 06 10", "Leica DG Macro-Elmarit 45mm F2.8 Asph. Mega OIS"); //PH
340 _olympusLensTypes.put("2 07 10", "Lumix G Vario 14-42mm F3.5-5.6 Asph. Mega OIS"); //20
341 _olympusLensTypes.put("2 08 10", "Lumix G Fisheye 8mm F3.5"); //PH
342 _olympusLensTypes.put("2 09 10", "Lumix G Vario 100-300mm F4.0-5.6 Mega OIS"); //11
343 _olympusLensTypes.put("2 10 10", "Lumix G 14mm F2.5 Asph."); //17
344 _olympusLensTypes.put("2 11 10", "Lumix G 12.5mm F12 3D"); //20 (H-FT012)
345 _olympusLensTypes.put("2 12 10", "Leica DG Summilux 25mm F1.4 Asph."); //20
346 _olympusLensTypes.put("2 13 10", "Lumix G X Vario PZ 45-175mm F4.0-5.6 Asph. Power OIS"); //20
347 _olympusLensTypes.put("2 14 10", "Lumix G X Vario PZ 14-42mm F3.5-5.6 Asph. Power OIS"); //20
348 _olympusLensTypes.put("2 15 10", "Lumix G X Vario 12-35mm F2.8 Asph. Power OIS"); //PH
349 _olympusLensTypes.put("2 16 10", "Lumix G Vario 45-150mm F4.0-5.6 Asph. Mega OIS"); //20
350 _olympusLensTypes.put("2 17 10", "Lumix G X Vario 35-100mm F2.8 Power OIS"); //PH
351 _olympusLensTypes.put("2 18 10", "Lumix G Vario 14-42mm F3.5-5.6 II Asph. Mega OIS"); //20
352 _olympusLensTypes.put("2 19 10", "Lumix G Vario 14-140mm F3.5-5.6 Asph. Power OIS"); //20
353 _olympusLensTypes.put("2 20 10", "Lumix G Vario 12-32mm F3.5-5.6 Asph. Mega OIS"); //20
354 _olympusLensTypes.put("2 21 10", "Leica DG Nocticron 42.5mm F1.2 Asph. Power OIS"); //20
355 _olympusLensTypes.put("2 22 10", "Leica DG Summilux 15mm F1.7 Asph."); //20
356 // '2 23 10", "Lumix G Vario 35-100mm F4.0-5.6 Asph. Mega OIS"); //20 (guess)
357 _olympusLensTypes.put("2 24 10", "Lumix G Macro 30mm F2.8 Asph. Mega OIS"); //20
358 _olympusLensTypes.put("2 25 10", "Lumix G 42.5mm F1.7 Asph. Power OIS"); //20
359 _olympusLensTypes.put("3 01 00", "Leica D Vario Elmarit 14-50mm F2.8-3.5 Asph."); //11
360 _olympusLensTypes.put("3 02 00", "Leica D Summilux 25mm F1.4 Asph."); //11
361 // Tamron lenses
362 _olympusLensTypes.put("5 01 10", "Tamron 14-150mm F3.5-5.8 Di III"); //20 (model C001)
363
364
365 _olympusExtenderTypes.put("0 00", "None");
366 _olympusExtenderTypes.put("0 04", "Olympus Zuiko Digital EC-14 1.4x Teleconverter");
367 _olympusExtenderTypes.put("0 08", "Olympus EX-25 Extension Tube");
368 _olympusExtenderTypes.put("0 10", "Olympus Zuiko Digital EC-20 2.0x Teleconverter");
369 }
370}
Note: See TracBrowser for help on using the repository browser.