1 | /*
|
---|
2 | * Copyright 2002-2012 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 | * http://drewnoakes.com/code/exif/
|
---|
19 | * http://code.google.com/p/metadata-extractor/
|
---|
20 | */
|
---|
21 | package com.drew.metadata.exif;
|
---|
22 |
|
---|
23 | import com.drew.lang.Rational;
|
---|
24 | import com.drew.lang.annotations.NotNull;
|
---|
25 | import com.drew.lang.annotations.Nullable;
|
---|
26 | import com.drew.metadata.TagDescriptor;
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Provides human-readable string representations of tag values stored in a <code>FujifilmMakernoteDirectory</code>.
|
---|
30 | * <p/>
|
---|
31 | * Fujifilm's digicam added the MakerNote tag from the Year2000's model (e.g.Finepix1400,
|
---|
32 | * Finepix4700). It uses IFD format and start from ASCII character 'FUJIFILM', and next 4
|
---|
33 | * bytes(value 0x000c) points the offset to first IFD entry. Example of actual data
|
---|
34 | * structure is shown below.
|
---|
35 | * <p/>
|
---|
36 | * <pre><code>
|
---|
37 | * :0000: 46 55 4A 49 46 49 4C 4D-0C 00 00 00 0F 00 00 00 :0000: FUJIFILM........
|
---|
38 | * :0010: 07 00 04 00 00 00 30 31-33 30 00 10 02 00 08 00 :0010: ......0130......
|
---|
39 | * </code></pre>
|
---|
40 | * <p/>
|
---|
41 | * There are two big differences to the other manufacturers.
|
---|
42 | * - Fujifilm's Exif data uses Motorola align, but MakerNote ignores it and uses Intel
|
---|
43 | * align.
|
---|
44 | * - The other manufacturer's MakerNote counts the "offset to data" from the first byte
|
---|
45 | * of TIFF header (same as the other IFD), but Fujifilm counts it from the first byte
|
---|
46 | * of MakerNote itself.
|
---|
47 | *
|
---|
48 | * @author Drew Noakes http://drewnoakes.com
|
---|
49 | */
|
---|
50 | public class FujifilmMakernoteDescriptor extends TagDescriptor<FujifilmMakernoteDirectory>
|
---|
51 | {
|
---|
52 | public FujifilmMakernoteDescriptor(@NotNull FujifilmMakernoteDirectory directory)
|
---|
53 | {
|
---|
54 | super(directory);
|
---|
55 | }
|
---|
56 |
|
---|
57 | @Nullable
|
---|
58 | public String getDescription(int tagType)
|
---|
59 | {
|
---|
60 | switch (tagType) {
|
---|
61 | case FujifilmMakernoteDirectory.TAG_FUJIFILM_SHARPNESS:
|
---|
62 | return getSharpnessDescription();
|
---|
63 | case FujifilmMakernoteDirectory.TAG_FUJIFILM_WHITE_BALANCE:
|
---|
64 | return getWhiteBalanceDescription();
|
---|
65 | case FujifilmMakernoteDirectory.TAG_FUJIFILM_COLOR_SATURATION:
|
---|
66 | return getColorDescription();
|
---|
67 | case FujifilmMakernoteDirectory.TAG_FUJIFILM_TONE:
|
---|
68 | return getToneDescription();
|
---|
69 | case FujifilmMakernoteDirectory.TAG_FUJIFILM_FLASH_MODE:
|
---|
70 | return getFlashModeDescription();
|
---|
71 | case FujifilmMakernoteDirectory.TAG_FUJIFILM_FLASH_STRENGTH:
|
---|
72 | return getFlashStrengthDescription();
|
---|
73 | case FujifilmMakernoteDirectory.TAG_FUJIFILM_MACRO:
|
---|
74 | return getMacroDescription();
|
---|
75 | case FujifilmMakernoteDirectory.TAG_FUJIFILM_FOCUS_MODE:
|
---|
76 | return getFocusModeDescription();
|
---|
77 | case FujifilmMakernoteDirectory.TAG_FUJIFILM_SLOW_SYNCH:
|
---|
78 | return getSlowSyncDescription();
|
---|
79 | case FujifilmMakernoteDirectory.TAG_FUJIFILM_PICTURE_MODE:
|
---|
80 | return getPictureModeDescription();
|
---|
81 | case FujifilmMakernoteDirectory.TAG_FUJIFILM_CONTINUOUS_TAKING_OR_AUTO_BRACKETTING:
|
---|
82 | return getContinuousTakingOrAutoBrackettingDescription();
|
---|
83 | case FujifilmMakernoteDirectory.TAG_FUJIFILM_BLUR_WARNING:
|
---|
84 | return getBlurWarningDescription();
|
---|
85 | case FujifilmMakernoteDirectory.TAG_FUJIFILM_FOCUS_WARNING:
|
---|
86 | return getFocusWarningDescription();
|
---|
87 | case FujifilmMakernoteDirectory.TAG_FUJIFILM_AE_WARNING:
|
---|
88 | return getAutoExposureWarningDescription();
|
---|
89 | default:
|
---|
90 | return super.getDescription(tagType);
|
---|
91 | }
|
---|
92 | }
|
---|
93 |
|
---|
94 | @Nullable
|
---|
95 | public String getSharpnessDescription()
|
---|
96 | {
|
---|
97 | final Integer value = _directory.getInteger(FujifilmMakernoteDirectory.TAG_FUJIFILM_SHARPNESS);
|
---|
98 | if (value==null)
|
---|
99 | return null;
|
---|
100 | switch (value) {
|
---|
101 | case 1:
|
---|
102 | return "Softest";
|
---|
103 | case 2:
|
---|
104 | return "Soft";
|
---|
105 | case 3:
|
---|
106 | return "Normal";
|
---|
107 | case 4:
|
---|
108 | return "Hard";
|
---|
109 | case 5:
|
---|
110 | return "Hardest";
|
---|
111 | default:
|
---|
112 | return "Unknown (" + value + ")";
|
---|
113 | }
|
---|
114 | }
|
---|
115 |
|
---|
116 | @Nullable
|
---|
117 | public String getWhiteBalanceDescription()
|
---|
118 | {
|
---|
119 | final Integer value = _directory.getInteger(FujifilmMakernoteDirectory.TAG_FUJIFILM_WHITE_BALANCE);
|
---|
120 | if (value==null)
|
---|
121 | return null;
|
---|
122 | switch (value) {
|
---|
123 | case 0:
|
---|
124 | return "Auto";
|
---|
125 | case 256:
|
---|
126 | return "Daylight";
|
---|
127 | case 512:
|
---|
128 | return "Cloudy";
|
---|
129 | case 768:
|
---|
130 | return "DaylightColor-fluorescence";
|
---|
131 | case 769:
|
---|
132 | return "DaywhiteColor-fluorescence";
|
---|
133 | case 770:
|
---|
134 | return "White-fluorescence";
|
---|
135 | case 1024:
|
---|
136 | return "Incandescence";
|
---|
137 | case 3840:
|
---|
138 | return "Custom white balance";
|
---|
139 | default:
|
---|
140 | return "Unknown (" + value + ")";
|
---|
141 | }
|
---|
142 | }
|
---|
143 |
|
---|
144 | @Nullable
|
---|
145 | public String getColorDescription()
|
---|
146 | {
|
---|
147 | final Integer value = _directory.getInteger(FujifilmMakernoteDirectory.TAG_FUJIFILM_COLOR_SATURATION);
|
---|
148 | if (value==null)
|
---|
149 | return null;
|
---|
150 | switch (value) {
|
---|
151 | case 0:
|
---|
152 | return "Normal (STD)";
|
---|
153 | case 256:
|
---|
154 | return "High (HARD)";
|
---|
155 | case 512:
|
---|
156 | return "Low (ORG)";
|
---|
157 | default:
|
---|
158 | return "Unknown (" + value + ")";
|
---|
159 | }
|
---|
160 | }
|
---|
161 |
|
---|
162 | @Nullable
|
---|
163 | public String getToneDescription()
|
---|
164 | {
|
---|
165 | final Integer value = _directory.getInteger(FujifilmMakernoteDirectory.TAG_FUJIFILM_TONE);
|
---|
166 | if (value==null)
|
---|
167 | return null;
|
---|
168 | switch (value) {
|
---|
169 | case 0:
|
---|
170 | return "Normal (STD)";
|
---|
171 | case 256:
|
---|
172 | return "High (HARD)";
|
---|
173 | case 512:
|
---|
174 | return "Low (ORG)";
|
---|
175 | default:
|
---|
176 | return "Unknown (" + value + ")";
|
---|
177 | }
|
---|
178 | }
|
---|
179 |
|
---|
180 | @Nullable
|
---|
181 | public String getFlashModeDescription()
|
---|
182 | {
|
---|
183 | final Integer value = _directory.getInteger(FujifilmMakernoteDirectory.TAG_FUJIFILM_FLASH_MODE);
|
---|
184 | if (value==null)
|
---|
185 | return null;
|
---|
186 | switch (value) {
|
---|
187 | case 0:
|
---|
188 | return "Auto";
|
---|
189 | case 1:
|
---|
190 | return "On";
|
---|
191 | case 2:
|
---|
192 | return "Off";
|
---|
193 | case 3:
|
---|
194 | return "Red-eye reduction";
|
---|
195 | default:
|
---|
196 | return "Unknown (" + value + ")";
|
---|
197 | }
|
---|
198 | }
|
---|
199 |
|
---|
200 | @Nullable
|
---|
201 | public String getFlashStrengthDescription()
|
---|
202 | {
|
---|
203 | Rational value = _directory.getRational(FujifilmMakernoteDirectory.TAG_FUJIFILM_FLASH_STRENGTH);
|
---|
204 | if (value==null)
|
---|
205 | return null;
|
---|
206 | return value.toSimpleString(false) + " EV (Apex)";
|
---|
207 | }
|
---|
208 |
|
---|
209 | @Nullable
|
---|
210 | public String getMacroDescription()
|
---|
211 | {
|
---|
212 | return getOnOffDescription(FujifilmMakernoteDirectory.TAG_FUJIFILM_MACRO);
|
---|
213 | }
|
---|
214 |
|
---|
215 | @Nullable
|
---|
216 | public String getFocusModeDescription()
|
---|
217 | {
|
---|
218 | final Integer value = _directory.getInteger(FujifilmMakernoteDirectory.TAG_FUJIFILM_FOCUS_MODE);
|
---|
219 | if (value==null)
|
---|
220 | return null;
|
---|
221 | switch (value) {
|
---|
222 | case 0:
|
---|
223 | return "Auto focus";
|
---|
224 | case 1:
|
---|
225 | return "Manual focus";
|
---|
226 | default:
|
---|
227 | return "Unknown (" + value + ")";
|
---|
228 | }
|
---|
229 | }
|
---|
230 |
|
---|
231 | @Nullable
|
---|
232 | public String getSlowSyncDescription()
|
---|
233 | {
|
---|
234 | return getOnOffDescription(FujifilmMakernoteDirectory.TAG_FUJIFILM_SLOW_SYNCH);
|
---|
235 | }
|
---|
236 |
|
---|
237 | @Nullable
|
---|
238 | public String getPictureModeDescription()
|
---|
239 | {
|
---|
240 | final Integer value = _directory.getInteger(FujifilmMakernoteDirectory.TAG_FUJIFILM_PICTURE_MODE);
|
---|
241 | if (value==null)
|
---|
242 | return null;
|
---|
243 | switch (value) {
|
---|
244 | case 0:
|
---|
245 | return "Auto";
|
---|
246 | case 1:
|
---|
247 | return "Portrait scene";
|
---|
248 | case 2:
|
---|
249 | return "Landscape scene";
|
---|
250 | case 4:
|
---|
251 | return "Sports scene";
|
---|
252 | case 5:
|
---|
253 | return "Night scene";
|
---|
254 | case 6:
|
---|
255 | return "Program AE";
|
---|
256 | case 256:
|
---|
257 | return "Aperture priority AE";
|
---|
258 | case 512:
|
---|
259 | return "Shutter priority AE";
|
---|
260 | case 768:
|
---|
261 | return "Manual exposure";
|
---|
262 | default:
|
---|
263 | return "Unknown (" + value + ")";
|
---|
264 | }
|
---|
265 | }
|
---|
266 |
|
---|
267 | @Nullable
|
---|
268 | public String getContinuousTakingOrAutoBrackettingDescription()
|
---|
269 | {
|
---|
270 | return getOnOffDescription(FujifilmMakernoteDirectory.TAG_FUJIFILM_CONTINUOUS_TAKING_OR_AUTO_BRACKETTING);
|
---|
271 | }
|
---|
272 |
|
---|
273 | @Nullable
|
---|
274 | public String getBlurWarningDescription()
|
---|
275 | {
|
---|
276 | final Integer value = _directory.getInteger(FujifilmMakernoteDirectory.TAG_FUJIFILM_BLUR_WARNING);
|
---|
277 | if (value==null)
|
---|
278 | return null;
|
---|
279 | switch (value) {
|
---|
280 | case 0:
|
---|
281 | return "No blur warning";
|
---|
282 | case 1:
|
---|
283 | return "Blur warning";
|
---|
284 | default:
|
---|
285 | return "Unknown (" + value + ")";
|
---|
286 | }
|
---|
287 | }
|
---|
288 |
|
---|
289 | @Nullable
|
---|
290 | public String getFocusWarningDescription()
|
---|
291 | {
|
---|
292 | final Integer value = _directory.getInteger(FujifilmMakernoteDirectory.TAG_FUJIFILM_FOCUS_WARNING);
|
---|
293 | if (value==null)
|
---|
294 | return null;
|
---|
295 | switch (value) {
|
---|
296 | case 0:
|
---|
297 | return "Auto focus good";
|
---|
298 | case 1:
|
---|
299 | return "Out of focus";
|
---|
300 | default:
|
---|
301 | return "Unknown (" + value + ")";
|
---|
302 | }
|
---|
303 | }
|
---|
304 |
|
---|
305 | @Nullable
|
---|
306 | public String getAutoExposureWarningDescription()
|
---|
307 | {
|
---|
308 | final Integer value = _directory.getInteger(FujifilmMakernoteDirectory.TAG_FUJIFILM_AE_WARNING);
|
---|
309 | if (value==null)
|
---|
310 | return null;
|
---|
311 | switch (value) {
|
---|
312 | case 0:
|
---|
313 | return "AE good";
|
---|
314 | case 1:
|
---|
315 | return "Over exposed (>1/1000s @ F11)";
|
---|
316 | default:
|
---|
317 | return "Unknown (" + value + ")";
|
---|
318 | }
|
---|
319 | }
|
---|
320 |
|
---|
321 |
|
---|
322 | @Nullable
|
---|
323 | private String getOnOffDescription(final int tagType)
|
---|
324 | {
|
---|
325 | final Integer value = _directory.getInteger(tagType);
|
---|
326 | if (value==null)
|
---|
327 | return null;
|
---|
328 | switch (value) {
|
---|
329 | case 0:
|
---|
330 | return "Off";
|
---|
331 | case 1:
|
---|
332 | return "On";
|
---|
333 | default:
|
---|
334 | return "Unknown (" + value + ")";
|
---|
335 | }
|
---|
336 | }
|
---|
337 | }
|
---|