Debian Codegraph @

src/com/drew/metadata/jfif/JfifDirectory.java

raw symbols SCIP
1 /*
2 * Copyright 2002-2019 Drew Noakes and contributors
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.jfif;
22
23 import com.drew.lang.annotations.NotNull;
24 import com.drew.metadata.Directory;
25 import com.drew.metadata.MetadataException;
26
27 import java.util.HashMap;
28
29 /**
30 * Directory of tags and values for the SOF0 Jfif segment. This segment holds basic metadata about the image.
31 *
32 * @author Yuri Binev, Drew Noakes
33 */
34 @SuppressWarnings("WeakerAccess")
35 public class JfifDirectory extends Directory
36 {
37 public static final int TAG_VERSION = 5;
38 /** Units for pixel density fields. One of None, Pixels per Inch, Pixels per Centimetre. */
39 public static final int TAG_UNITS = 7;
40 public static final int TAG_RESX = 8;
41 public static final int TAG_RESY = 10;
42 public static final int TAG_THUMB_WIDTH = 12;
43 public static final int TAG_THUMB_HEIGHT = 13;
44
45 @NotNull
46 private static final HashMap<Integer, String> _tagNameMap = new HashMap<Integer, String>();
47
48 static
49 {
50 _tagNameMap.put(TAG_VERSION, "Version");
51 _tagNameMap.put(TAG_UNITS, "Resolution Units");
52 _tagNameMap.put(TAG_RESY, "Y Resolution");
53 _tagNameMap.put(TAG_RESX, "X Resolution");
54 _tagNameMap.put(TAG_THUMB_WIDTH, "Thumbnail Width Pixels");
55 _tagNameMap.put(TAG_THUMB_HEIGHT, "Thumbnail Height Pixels");
56 }
57
58 public JfifDirectory()
59 {
60 this.setDescriptor(new JfifDescriptor(this));
61 }
62
63 @Override
64 @NotNull
65 public String getName()
66 {
67 return "JFIF";
68 }
69
70 @Override
71 @NotNull
72 protected HashMap<Integer, String> getTagNameMap()
73 {
74 return _tagNameMap;
75 }
76
77 public int getVersion() throws MetadataException
78 {
79 return getInt(JfifDirectory.TAG_VERSION);
80 }
81
82 public int getResUnits() throws MetadataException
83 {
84 return getInt(JfifDirectory.TAG_UNITS);
85 }
86
87 /**
88 * @deprecated use {@link #getResY} instead.
89 */
90 @Deprecated
91 public int getImageWidth() throws MetadataException
92 {
93 return getInt(JfifDirectory.TAG_RESY);
94 }
95
96 public int getResY() throws MetadataException
97 {
98 return getInt(JfifDirectory.TAG_RESY);
99 }
100
101 /**
102 * @deprecated use {@link #getResX} instead.
103 */
104 @Deprecated
105 public int getImageHeight() throws MetadataException
106 {
107 return getInt(JfifDirectory.TAG_RESX);
108 }
109
110 public int getResX() throws MetadataException
111 {
112 return getInt(JfifDirectory.TAG_RESX);
113 }
114 }