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

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

update to metadata-extractor 2.9.1

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