Debian Codegraph @

src/com/drew/metadata/exif/makernotes/OlympusEquipmentMakernoteDescriptor.java

raw symbols SCIP
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 */
21 package com.drew.metadata.exif.makernotes;
22
23 import com.drew.lang.annotations.NotNull;
24 import com.drew.lang.annotations.Nullable;
25 import com.drew.metadata.TagDescriptor;
26
27 import java.text.DecimalFormat;
28 import java.util.HashMap;
29
30 import 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 */
42 @SuppressWarnings("WeakerAccess")
43 public class OlympusEquipmentMakernoteDescriptor extends TagDescriptor<OlympusEquipmentMakernoteDirectory>
44 {
45 public OlympusEquipmentMakernoteDescriptor(@NotNull OlympusEquipmentMakernoteDirectory directory)
46 {
47 super(directory);
48 }
49
50 @Override
51 @Nullable
52 public String getDescription(int tagType)
53 {
54 switch (tagType) {
55 case TAG_EQUIPMENT_VERSION:
56 return getEquipmentVersionDescription();
57 case TAG_CAMERA_TYPE_2:
58 return getCameraType2Description();
59 case TAG_FOCAL_PLANE_DIAGONAL:
60 return getFocalPlaneDiagonalDescription();
61 case TAG_BODY_FIRMWARE_VERSION:
62 return getBodyFirmwareVersionDescription();
63 case TAG_LENS_TYPE:
64 return getLensTypeDescription();
65 case TAG_LENS_FIRMWARE_VERSION:
66 return getLensFirmwareVersionDescription();
67 case TAG_MAX_APERTURE_AT_MIN_FOCAL:
68 return getMaxApertureAtMinFocalDescription();
69 case TAG_MAX_APERTURE_AT_MAX_FOCAL:
70 return getMaxApertureAtMaxFocalDescription();
71 case TAG_MAX_APERTURE:
72 return getMaxApertureDescription();
73 case TAG_LENS_PROPERTIES:
74 return getLensPropertiesDescription();
75 case TAG_EXTENDER:
76 return getExtenderDescription();
77 case TAG_FLASH_TYPE:
78 return getFlashTypeDescription();
79 case TAG_FLASH_MODEL:
80 return getFlashModelDescription();
81 default:
82 return super.getDescription(tagType);
83 }
84 }
85
86 @Nullable
87 public String getEquipmentVersionDescription()
88 {
89 return getVersionBytesDescription(TAG_EQUIPMENT_VERSION, 4);
90 }
91
92 @Nullable
93 public String getCameraType2Description()
94 {
95 String cameratype = _directory.getString(TAG_CAMERA_TYPE_2);
96 if(cameratype == null)
97 return null;
98
99 if(OlympusMakernoteDirectory.OlympusCameraTypes.containsKey(cameratype))
100 return OlympusMakernoteDirectory.OlympusCameraTypes.get(cameratype);
101
102 return cameratype;
103 }
104
105 @Nullable
106 public String getFocalPlaneDiagonalDescription()
107 {
108 return _directory.getString(TAG_FOCAL_PLANE_DIAGONAL) + " mm";
109 }
110
111 @Nullable
112 public String getBodyFirmwareVersionDescription()
113 {
114 Integer value = _directory.getInteger(TAG_BODY_FIRMWARE_VERSION);
115 if (value == null)
116 return null;
117
118 String hex = String.format("%04X", value);
119 return String.format("%s.%s",
120 hex.substring(0, hex.length() - 3),
121 hex.substring(hex.length() - 3));
122 }
123
124 @Nullable
125 public String getLensTypeDescription()
126 {
127 String str = _directory.getString(TAG_LENS_TYPE);
128
129 if (str == null)
130 return null;
131
132 // The String contains six numbers:
133 //
134 // - Make
135 // - Unknown
136 // - Model
137 // - Sub-model
138 // - Unknown
139 // - Unknown
140 //
141 // Only the Make, Model and Sub-model are used to identify the lens type
142 String[] values = str.split(" ");
143
144 if (values.length < 6)
145 return null;
146
147 try {
148 int num1 = Integer.parseInt(values[0]);
149 int num2 = Integer.parseInt(values[2]);
150 int num3 = Integer.parseInt(values[3]);
151 return _olympusLensTypes.get(String.format("%X %02X %02X", num1, num2, num3));
152 } catch (NumberFormatException e) {
153 return null;
154 }
155 }
156
157 @Nullable
158 public String getLensFirmwareVersionDescription()
159 {
160 Integer value = _directory.getInteger(TAG_LENS_FIRMWARE_VERSION);
161 if (value == null)
162 return null;
163
164 String hex = String.format("%04X", value);
165 return String.format("%s.%s",
166 hex.substring(0, hex.length() - 3),
167 hex.substring(hex.length() - 3));
168 }
169
170 @Nullable
171 public String getMaxApertureAtMinFocalDescription()
172 {
173 Integer value = _directory.getInteger(TAG_MAX_APERTURE_AT_MIN_FOCAL);
174 if (value == null)
175 return null;
176
177 DecimalFormat format = new DecimalFormat("0.#");
178 return format.format(CalcMaxAperture(value));
179 }
180
181 @Nullable
182 public String getMaxApertureAtMaxFocalDescription()
183 {
184 Integer value = _directory.getInteger(TAG_MAX_APERTURE_AT_MAX_FOCAL);
185 if (value == null)
186 return null;
187
188 DecimalFormat format = new DecimalFormat("0.#");
189 return format.format(CalcMaxAperture(value));
190 }
191
192 @Nullable
193 public String getMaxApertureDescription()
194 {
195 Integer value = _directory.getInteger(TAG_MAX_APERTURE);
196 if (value == null)
197 return null;
198
199 DecimalFormat format = new DecimalFormat("0.#");
200 return format.format(CalcMaxAperture(value));
201 }
202
203 private static double CalcMaxAperture(int value)
204 {
205 return Math.pow(Math.sqrt(2.00), value / 256.0);
206 }
207
208 @Nullable
209 public String getLensPropertiesDescription()
210 {
211 Integer value = _directory.getInteger(TAG_LENS_PROPERTIES);
212 if (value == null)
213 return null;
214
215 return String.format("0x%04X", value);
216 }
217
218 @Nullable
219 public String getExtenderDescription()
220 {
221 String str = _directory.getString(TAG_EXTENDER);
222
223 if (str == null)
224 return null;
225
226 // The String contains six numbers:
227 //
228 // - Make
229 // - Unknown
230 // - Model
231 // - Sub-model
232 // - Unknown
233 // - Unknown
234 //
235 // Only the Make and Model are used to identify the extender
236 String[] values = str.split(" ");
237
238 if (values.length < 6)
239 return null;
240
241 try {
242 int num1 = Integer.parseInt(values[0]);
243 int num2 = Integer.parseInt(values[2]);
244 String extenderType = String.format("%X %02X", num1, num2);
245 return _olympusExtenderTypes.get(extenderType);
246 } catch (NumberFormatException e) {
247 return null;
248 }
249 }
250
251 @Nullable
252 public String getFlashTypeDescription()
253 {
254 return getIndexedDescription(TAG_FLASH_TYPE,
255 "None", null, "Simple E-System", "E-System");
256 }
257
258 @Nullable
259 public String getFlashModelDescription()
260 {
261 return getIndexedDescription(TAG_FLASH_MODEL,
262 "None", "FL-20", "FL-50", "RF-11", "TF-22", "FL-36", "FL-50R", "FL-36R");
263 }
264
265 private static final HashMap<String, String> _olympusLensTypes = new HashMap<String, String>();
266 private static final HashMap<String, String> _olympusExtenderTypes = new HashMap<String, String>();
267
268 static {
269 _olympusLensTypes.put("0 00 00", "None");
270 // Olympus lenses (also Kenko Tokina)
271 _olympusLensTypes.put("0 01 00", "Olympus Zuiko Digital ED 50mm F2.0 Macro");
272 _olympusLensTypes.put("0 01 01", "Olympus Zuiko Digital 40-150mm F3.5-4.5"); //8
273 _olympusLensTypes.put("0 01 10", "Olympus M.Zuiko Digital ED 14-42mm F3.5-5.6"); //PH (E-P1 pre-production)
274 _olympusLensTypes.put("0 02 00", "Olympus Zuiko Digital ED 150mm F2.0");
275 _olympusLensTypes.put("0 02 10", "Olympus M.Zuiko Digital 17mm F2.8 Pancake"); //PH (E-P1 pre-production)
276 _olympusLensTypes.put("0 03 00", "Olympus Zuiko Digital ED 300mm F2.8");
277 _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)
278 _olympusLensTypes.put("0 04 10", "Olympus M.Zuiko Digital ED 9-18mm F4.0-5.6"); //11
279 _olympusLensTypes.put("0 05 00", "Olympus Zuiko Digital 14-54mm F2.8-3.5");
280 _olympusLensTypes.put("0 05 01", "Olympus Zuiko Digital Pro ED 90-250mm F2.8"); //9
281 _olympusLensTypes.put("0 05 10", "Olympus M.Zuiko Digital ED 14-42mm F3.5-5.6 L"); //11 (E-PL1)
282 _olympusLensTypes.put("0 06 00", "Olympus Zuiko Digital ED 50-200mm F2.8-3.5");
283 _olympusLensTypes.put("0 06 01", "Olympus Zuiko Digital ED 8mm F3.5 Fisheye"); //9
284 _olympusLensTypes.put("0 06 10", "Olympus M.Zuiko Digital ED 40-150mm F4.0-5.6"); //PH
285 _olympusLensTypes.put("0 07 00", "Olympus Zuiko Digital 11-22mm F2.8-3.5");
286 _olympusLensTypes.put("0 07 01", "Olympus Zuiko Digital 18-180mm F3.5-6.3"); //6
287 _olympusLensTypes.put("0 07 10", "Olympus M.Zuiko Digital ED 12mm F2.0"); //PH
288 _olympusLensTypes.put("0 08 01", "Olympus Zuiko Digital 70-300mm F4.0-5.6"); //7 (seen as release 1 - PH)
289 _olympusLensTypes.put("0 08 10", "Olympus M.Zuiko Digital ED 75-300mm F4.8-6.7"); //PH
290 _olympusLensTypes.put("0 09 10", "Olympus M.Zuiko Digital 14-42mm F3.5-5.6 II"); //PH (E-PL2)
291 _olympusLensTypes.put("0 10 01", "Kenko Tokina Reflex 300mm F6.3 MF Macro"); //20
292 _olympusLensTypes.put("0 10 10", "Olympus M.Zuiko Digital ED 12-50mm F3.5-6.3 EZ"); //PH
293 _olympusLensTypes.put("0 11 10", "Olympus M.Zuiko Digital 45mm F1.8"); //17
294 _olympusLensTypes.put("0 12 10", "Olympus M.Zuiko Digital ED 60mm F2.8 Macro"); //20
295 _olympusLensTypes.put("0 13 10", "Olympus M.Zuiko Digital 14-42mm F3.5-5.6 II R"); //PH/20
296 _olympusLensTypes.put("0 14 10", "Olympus M.Zuiko Digital ED 40-150mm F4.0-5.6 R"); //19
297 // '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)
298 _olympusLensTypes.put("0 15 00", "Olympus Zuiko Digital ED 7-14mm F4.0");
299 _olympusLensTypes.put("0 15 10", "Olympus M.Zuiko Digital ED 75mm F1.8"); //PH
300 _olympusLensTypes.put("0 16 10", "Olympus M.Zuiko Digital 17mm F1.8"); //20
301 _olympusLensTypes.put("0 17 00", "Olympus Zuiko Digital Pro ED 35-100mm F2.0"); //7
302 _olympusLensTypes.put("0 18 00", "Olympus Zuiko Digital 14-45mm F3.5-5.6");
303 _olympusLensTypes.put("0 18 10", "Olympus M.Zuiko Digital ED 75-300mm F4.8-6.7 II"); //20
304 _olympusLensTypes.put("0 19 10", "Olympus M.Zuiko Digital ED 12-40mm F2.8 Pro"); //PH
305 _olympusLensTypes.put("0 20 00", "Olympus Zuiko Digital 35mm F3.5 Macro"); //9
306 _olympusLensTypes.put("0 20 10", "Olympus M.Zuiko Digital ED 40-150mm F2.8 Pro"); //20
307 _olympusLensTypes.put("0 21 10", "Olympus M.Zuiko Digital ED 14-42mm F3.5-5.6 EZ"); //20
308 _olympusLensTypes.put("0 22 00", "Olympus Zuiko Digital 17.5-45mm F3.5-5.6"); //9
309 _olympusLensTypes.put("0 22 10", "Olympus M.Zuiko Digital 25mm F1.8"); //20
310 _olympusLensTypes.put("0 23 00", "Olympus Zuiko Digital ED 14-42mm F3.5-5.6"); //PH
311 _olympusLensTypes.put("0 23 10", "Olympus M.Zuiko Digital ED 7-14mm F2.8 Pro"); //20
312 _olympusLensTypes.put("0 24 00", "Olympus Zuiko Digital ED 40-150mm F4.0-5.6"); //PH
313 _olympusLensTypes.put("0 24 10", "Olympus M.Zuiko Digital ED 300mm F4.0 IS Pro"); //20
314 _olympusLensTypes.put("0 25 10", "Olympus M.Zuiko Digital ED 8mm F1.8 Fisheye Pro"); //20
315 _olympusLensTypes.put("0 30 00", "Olympus Zuiko Digital ED 50-200mm F2.8-3.5 SWD"); //7
316 _olympusLensTypes.put("0 31 00", "Olympus Zuiko Digital ED 12-60mm F2.8-4.0 SWD"); //7
317 _olympusLensTypes.put("0 32 00", "Olympus Zuiko Digital ED 14-35mm F2.0 SWD"); //PH
318 _olympusLensTypes.put("0 33 00", "Olympus Zuiko Digital 25mm F2.8"); //PH
319 _olympusLensTypes.put("0 34 00", "Olympus Zuiko Digital ED 9-18mm F4.0-5.6"); //7
320 _olympusLensTypes.put("0 35 00", "Olympus Zuiko Digital 14-54mm F2.8-3.5 II"); //PH
321 // Sigma lenses
322 _olympusLensTypes.put("1 01 00", "Sigma 18-50mm F3.5-5.6 DC"); //8
323 _olympusLensTypes.put("1 01 10", "Sigma 30mm F2.8 EX DN"); //20
324 _olympusLensTypes.put("1 02 00", "Sigma 55-200mm F4.0-5.6 DC");
325 _olympusLensTypes.put("1 02 10", "Sigma 19mm F2.8 EX DN"); //20
326 _olympusLensTypes.put("1 03 00", "Sigma 18-125mm F3.5-5.6 DC");
327 _olympusLensTypes.put("1 03 10", "Sigma 30mm F2.8 DN | A"); //20
328 _olympusLensTypes.put("1 04 00", "Sigma 18-125mm F3.5-5.6 DC"); //7
329 _olympusLensTypes.put("1 04 10", "Sigma 19mm F2.8 DN | A"); //20
330 _olympusLensTypes.put("1 05 00", "Sigma 30mm F1.4 EX DC HSM"); //10
331 _olympusLensTypes.put("1 05 10", "Sigma 60mm F2.8 DN | A"); //20
332 _olympusLensTypes.put("1 06 00", "Sigma APO 50-500mm F4.0-6.3 EX DG HSM"); //6
333 _olympusLensTypes.put("1 07 00", "Sigma Macro 105mm F2.8 EX DG"); //PH
334 _olympusLensTypes.put("1 08 00", "Sigma APO Macro 150mm F2.8 EX DG HSM"); //PH
335 _olympusLensTypes.put("1 09 00", "Sigma 18-50mm F2.8 EX DC Macro"); //20
336 _olympusLensTypes.put("1 10 00", "Sigma 24mm F1.8 EX DG Aspherical Macro"); //PH
337 _olympusLensTypes.put("1 11 00", "Sigma APO 135-400mm F4.5-5.6 DG"); //11
338 _olympusLensTypes.put("1 12 00", "Sigma APO 300-800mm F5.6 EX DG HSM"); //11
339 _olympusLensTypes.put("1 13 00", "Sigma 30mm F1.4 EX DC HSM"); //11
340 _olympusLensTypes.put("1 14 00", "Sigma APO 50-500mm F4.0-6.3 EX DG HSM"); //11
341 _olympusLensTypes.put("1 15 00", "Sigma 10-20mm F4.0-5.6 EX DC HSM"); //11
342 _olympusLensTypes.put("1 16 00", "Sigma APO 70-200mm F2.8 II EX DG Macro HSM"); //11
343 _olympusLensTypes.put("1 17 00", "Sigma 50mm F1.4 EX DG HSM"); //11
344 // Panasonic/Leica lenses
345 _olympusLensTypes.put("2 01 00", "Leica D Vario Elmarit 14-50mm F2.8-3.5 Asph."); //11
346 _olympusLensTypes.put("2 01 10", "Lumix G Vario 14-45mm F3.5-5.6 Asph. Mega OIS"); //16
347 _olympusLensTypes.put("2 02 00", "Leica D Summilux 25mm F1.4 Asph."); //11
348 _olympusLensTypes.put("2 02 10", "Lumix G Vario 45-200mm F4.0-5.6 Mega OIS"); //16
349 _olympusLensTypes.put("2 03 00", "Leica D Vario Elmar 14-50mm F3.8-5.6 Asph. Mega OIS"); //11
350 _olympusLensTypes.put("2 03 01", "Leica D Vario Elmar 14-50mm F3.8-5.6 Asph."); //14 (L10 kit)
351 _olympusLensTypes.put("2 03 10", "Lumix G Vario HD 14-140mm F4.0-5.8 Asph. Mega OIS"); //16
352 _olympusLensTypes.put("2 04 00", "Leica D Vario Elmar 14-150mm F3.5-5.6"); //13
353 _olympusLensTypes.put("2 04 10", "Lumix G Vario 7-14mm F4.0 Asph."); //PH (E-P1 pre-production)
354 _olympusLensTypes.put("2 05 10", "Lumix G 20mm F1.7 Asph."); //16
355 _olympusLensTypes.put("2 06 10", "Leica DG Macro-Elmarit 45mm F2.8 Asph. Mega OIS"); //PH
356 _olympusLensTypes.put("2 07 10", "Lumix G Vario 14-42mm F3.5-5.6 Asph. Mega OIS"); //20
357 _olympusLensTypes.put("2 08 10", "Lumix G Fisheye 8mm F3.5"); //PH
358 _olympusLensTypes.put("2 09 10", "Lumix G Vario 100-300mm F4.0-5.6 Mega OIS"); //11
359 _olympusLensTypes.put("2 10 10", "Lumix G 14mm F2.5 Asph."); //17
360 _olympusLensTypes.put("2 11 10", "Lumix G 12.5mm F12 3D"); //20 (H-FT012)
361 _olympusLensTypes.put("2 12 10", "Leica DG Summilux 25mm F1.4 Asph."); //20
362 _olympusLensTypes.put("2 13 10", "Lumix G X Vario PZ 45-175mm F4.0-5.6 Asph. Power OIS"); //20
363 _olympusLensTypes.put("2 14 10", "Lumix G X Vario PZ 14-42mm F3.5-5.6 Asph. Power OIS"); //20
364 _olympusLensTypes.put("2 15 10", "Lumix G X Vario 12-35mm F2.8 Asph. Power OIS"); //PH
365 _olympusLensTypes.put("2 16 10", "Lumix G Vario 45-150mm F4.0-5.6 Asph. Mega OIS"); //20
366 _olympusLensTypes.put("2 17 10", "Lumix G X Vario 35-100mm F2.8 Power OIS"); //PH
367 _olympusLensTypes.put("2 18 10", "Lumix G Vario 14-42mm F3.5-5.6 II Asph. Mega OIS"); //20
368 _olympusLensTypes.put("2 19 10", "Lumix G Vario 14-140mm F3.5-5.6 Asph. Power OIS"); //20
369 _olympusLensTypes.put("2 20 10", "Lumix G Vario 12-32mm F3.5-5.6 Asph. Mega OIS"); //20
370 _olympusLensTypes.put("2 21 10", "Leica DG Nocticron 42.5mm F1.2 Asph. Power OIS"); //20
371 _olympusLensTypes.put("2 22 10", "Leica DG Summilux 15mm F1.7 Asph."); //20
372 // '2 23 10", "Lumix G Vario 35-100mm F4.0-5.6 Asph. Mega OIS"); //20 (guess)
373 _olympusLensTypes.put("2 24 10", "Lumix G Macro 30mm F2.8 Asph. Mega OIS"); //20
374 _olympusLensTypes.put("2 25 10", "Lumix G 42.5mm F1.7 Asph. Power OIS"); //20
375 _olympusLensTypes.put("3 01 00", "Leica D Vario Elmarit 14-50mm F2.8-3.5 Asph."); //11
376 _olympusLensTypes.put("3 02 00", "Leica D Summilux 25mm F1.4 Asph."); //11
377 // Tamron lenses
378 _olympusLensTypes.put("5 01 10", "Tamron 14-150mm F3.5-5.8 Di III"); //20 (model C001)
379
380
381 _olympusExtenderTypes.put("0 00", "None");
382 _olympusExtenderTypes.put("0 04", "Olympus Zuiko Digital EC-14 1.4x Teleconverter");
383 _olympusExtenderTypes.put("0 08", "Olympus EX-25 Extension Tube");
384 _olympusExtenderTypes.put("0 10", "Olympus Zuiko Digital EC-20 2.0x Teleconverter");
385 }
386 }