source: josm/trunk/src/com/drew/metadata/exif/makernotes/OlympusImageProcessingMakernoteDescriptor.java@ 13061

Last change on this file since 13061 was 13061, checked in by Don-vip, 6 years ago

fix #15505 - update to metadata-extractor 2.10.1

  • Property svn:eol-style set to native
File size: 7.2 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 static com.drew.metadata.exif.makernotes.OlympusImageProcessingMakernoteDirectory.*;
28
29/**
30 * Provides human-readable String representations of tag values stored in a {@link OlympusImageProcessingMakernoteDirectory}.
31 * <p>
32 * Some Description functions converted from Exiftool version 10.33 created by Phil Harvey
33 * http://www.sno.phy.queensu.ca/~phil/exiftool/
34 * lib\Image\ExifTool\Olympus.pm
35 *
36 * @author Kevin Mott https://github.com/kwhopper
37 * @author Drew Noakes https://drewnoakes.com
38 */
39@SuppressWarnings("WeakerAccess")
40public class OlympusImageProcessingMakernoteDescriptor extends TagDescriptor<OlympusImageProcessingMakernoteDirectory>
41{
42 public OlympusImageProcessingMakernoteDescriptor(@NotNull OlympusImageProcessingMakernoteDirectory directory)
43 {
44 super(directory);
45 }
46
47 @Override
48 @Nullable
49 public String getDescription(int tagType)
50 {
51 switch (tagType) {
52 case TagImageProcessingVersion:
53 return getImageProcessingVersionDescription();
54 case TagColorMatrix:
55 return getColorMatrixDescription();
56 case TagNoiseReduction2:
57 return getNoiseReduction2Description();
58 case TagDistortionCorrection2:
59 return getDistortionCorrection2Description();
60 case TagShadingCompensation2:
61 return getShadingCompensation2Description();
62 case TagMultipleExposureMode:
63 return getMultipleExposureModeDescription();
64 case TagAspectRatio:
65 return getAspectRatioDescription();
66 case TagKeystoneCompensation:
67 return getKeystoneCompensationDescription();
68 case TagKeystoneDirection:
69 return getKeystoneDirectionDescription();
70 default:
71 return super.getDescription(tagType);
72 }
73 }
74
75 @Nullable
76 public String getImageProcessingVersionDescription()
77 {
78 return getVersionBytesDescription(TagImageProcessingVersion, 4);
79 }
80
81 @Nullable
82 public String getColorMatrixDescription()
83 {
84 int[] obj = _directory.getIntArray(TagColorMatrix);
85 if (obj == null)
86 return null;
87
88 StringBuilder sb = new StringBuilder();
89 for (int i = 0; i < obj.length; i++) {
90 if (i != 0)
91 sb.append(" ");
92 sb.append((short)obj[i]);
93 }
94 return sb.toString();
95 }
96
97 @Nullable
98 public String getNoiseReduction2Description()
99 {
100 Integer value = _directory.getInteger(TagNoiseReduction2);
101 if (value == null)
102 return null;
103
104 if (value == 0)
105 return "(none)";
106
107 StringBuilder sb = new StringBuilder();
108 short v = value.shortValue();
109
110 if (( v & 1) != 0) sb.append("Noise Reduction, ");
111 if (((v >> 1) & 1) != 0) sb.append("Noise Filter, ");
112 if (((v >> 2) & 1) != 0) sb.append("Noise Filter (ISO Boost), ");
113
114 return sb.substring(0, sb.length() - 2);
115 }
116
117 @Nullable
118 public String getDistortionCorrection2Description()
119 {
120 return getIndexedDescription(TagDistortionCorrection2, "Off", "On");
121 }
122
123 @Nullable
124 public String getShadingCompensation2Description()
125 {
126 return getIndexedDescription(TagShadingCompensation2, "Off", "On");
127 }
128
129 @Nullable
130 public String getMultipleExposureModeDescription()
131 {
132 int[] values = _directory.getIntArray(TagMultipleExposureMode);
133 if (values == null)
134 {
135 // check if it's only one value long also
136 Integer value = _directory.getInteger(TagMultipleExposureMode);
137 if(value == null)
138 return null;
139
140 values = new int[1];
141 values[0] = value;
142 }
143
144 if (values.length == 0)
145 return null;
146
147 StringBuilder sb = new StringBuilder();
148
149 switch ((short)values[0])
150 {
151 case 0:
152 sb.append("Off");
153 break;
154 case 2:
155 sb.append("On (2 frames)");
156 break;
157 case 3:
158 sb.append("On (3 frames)");
159 break;
160 default:
161 sb.append("Unknown (").append((short)values[0]).append(")");
162 break;
163 }
164
165 if (values.length > 1)
166 sb.append("; ").append((short)values[1]);
167
168 return sb.toString();
169 }
170
171 @Nullable
172 public String getAspectRatioDescription()
173 {
174 byte[] values = _directory.getByteArray(TagAspectRatio);
175 if (values == null || values.length < 2)
176 return null;
177
178 String join = String.format("%d %d", values[0], values[1]);
179
180 String ret;
181 if(join.equals("1 1"))
182 ret = "4:3";
183 else if(join.equals("1 4"))
184 ret = "1:1";
185 else if(join.equals("2 1"))
186 ret = "3:2 (RAW)";
187 else if(join.equals("2 2"))
188 ret = "3:2";
189 else if(join.equals("3 1"))
190 ret = "16:9 (RAW)";
191 else if(join.equals("3 3"))
192 ret = "16:9";
193 else if(join.equals("4 1"))
194 ret = "1:1 (RAW)";
195 else if(join.equals("4 4"))
196 ret = "6:6";
197 else if(join.equals("5 5"))
198 ret = "5:4";
199 else if(join.equals("6 6"))
200 ret = "7:6";
201 else if(join.equals("7 7"))
202 ret = "6:5";
203 else if(join.equals("8 8"))
204 ret = "7:5";
205 else if(join.equals("9 1"))
206 ret = "3:4 (RAW)";
207 else if(join.equals("9 9"))
208 ret = "3:4";
209 else
210 ret = "Unknown (" + join + ")";
211
212 return ret;
213 }
214
215 @Nullable
216 public String getKeystoneCompensationDescription()
217 {
218 byte[] values = _directory.getByteArray(TagKeystoneCompensation);
219 if (values == null || values.length < 2)
220 return null;
221
222 String join = String.format("%d %d", values[0], values[1]);
223
224 String ret;
225 if(join.equals("0 0"))
226 ret = "Off";
227 else if(join.equals("0 1"))
228 ret = "On";
229 else
230 ret = "Unknown (" + join + ")";
231
232 return ret;
233 }
234
235 @Nullable
236 public String getKeystoneDirectionDescription()
237 {
238 return getIndexedDescription(TagKeystoneDirection, "Vertical", "Horizontal");
239 }
240}
Note: See TracBrowser for help on using the repository browser.