source: josm/trunk/src/com/drew/metadata/jpeg/JpegDescriptor.java@ 8132

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

fix #11162 - update to metadata-extractor 2.7.2

File size: 4.6 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.jpeg;
22
23import com.drew.lang.annotations.NotNull;
24import com.drew.lang.annotations.Nullable;
25import com.drew.metadata.TagDescriptor;
26
27/**
28 * Provides human-readable string versions of the tags stored in a JpegDirectory.
29 * Thanks to Darrell Silver (www.darrellsilver.com) for the initial version of this class.
30 *
31 * @author Drew Noakes https://drewnoakes.com
32 */
33public class JpegDescriptor extends TagDescriptor<JpegDirectory>
34{
35 public JpegDescriptor(@NotNull JpegDirectory directory)
36 {
37 super(directory);
38 }
39
40 @Override
41 @Nullable
42 public String getDescription(int tagType)
43 {
44 switch (tagType)
45 {
46 case JpegDirectory.TAG_COMPRESSION_TYPE:
47 return getImageCompressionTypeDescription();
48 case JpegDirectory.TAG_COMPONENT_DATA_1:
49 return getComponentDataDescription(0);
50 case JpegDirectory.TAG_COMPONENT_DATA_2:
51 return getComponentDataDescription(1);
52 case JpegDirectory.TAG_COMPONENT_DATA_3:
53 return getComponentDataDescription(2);
54 case JpegDirectory.TAG_COMPONENT_DATA_4:
55 return getComponentDataDescription(3);
56 case JpegDirectory.TAG_DATA_PRECISION:
57 return getDataPrecisionDescription();
58 case JpegDirectory.TAG_IMAGE_HEIGHT:
59 return getImageHeightDescription();
60 case JpegDirectory.TAG_IMAGE_WIDTH:
61 return getImageWidthDescription();
62 default:
63 return super.getDescription(tagType);
64 }
65 }
66
67 @Nullable
68 public String getImageCompressionTypeDescription()
69 {
70 Integer value = _directory.getInteger(JpegDirectory.TAG_COMPRESSION_TYPE);
71 if (value==null)
72 return null;
73 // Note there is no 2 or 12
74 switch (value) {
75 case 0: return "Baseline";
76 case 1: return "Extended sequential, Huffman";
77 case 2: return "Progressive, Huffman";
78 case 3: return "Lossless, Huffman";
79 case 5: return "Differential sequential, Huffman";
80 case 6: return "Differential progressive, Huffman";
81 case 7: return "Differential lossless, Huffman";
82 case 8: return "Reserved for JPEG extensions";
83 case 9: return "Extended sequential, arithmetic";
84 case 10: return "Progressive, arithmetic";
85 case 11: return "Lossless, arithmetic";
86 case 13: return "Differential sequential, arithmetic";
87 case 14: return "Differential progressive, arithmetic";
88 case 15: return "Differential lossless, arithmetic";
89 default:
90 return "Unknown type: "+ value;
91 }
92 }
93 @Nullable
94 public String getImageWidthDescription()
95 {
96 final String value = _directory.getString(JpegDirectory.TAG_IMAGE_WIDTH);
97 if (value==null)
98 return null;
99 return value + " pixels";
100 }
101
102 @Nullable
103 public String getImageHeightDescription()
104 {
105 final String value = _directory.getString(JpegDirectory.TAG_IMAGE_HEIGHT);
106 if (value==null)
107 return null;
108 return value + " pixels";
109 }
110
111 @Nullable
112 public String getDataPrecisionDescription()
113 {
114 final String value = _directory.getString(JpegDirectory.TAG_DATA_PRECISION);
115 if (value==null)
116 return null;
117 return value + " bits";
118 }
119
120 @Nullable
121 public String getComponentDataDescription(int componentNumber)
122 {
123 JpegComponent value = _directory.getComponent(componentNumber);
124
125 if (value==null)
126 return null;
127
128 return value.getComponentName() + " component: Quantization table " + value.getQuantizationTableNumber()
129 + ", Sampling factors " + value.getHorizontalSamplingFactor()
130 + " horiz/" + value.getVerticalSamplingFactor() + " vert";
131 }
132}
Note: See TracBrowser for help on using the repository browser.