Debian Codegraph @

src/com/drew/metadata/photoshop/PsdHeaderDescriptor.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
22 package com.drew.metadata.photoshop;
23
24 import com.drew.lang.annotations.NotNull;
25 import com.drew.lang.annotations.Nullable;
26 import com.drew.metadata.TagDescriptor;
27
28 import static com.drew.metadata.photoshop.PsdHeaderDirectory.*;
29
30 /**
31 * @author Drew Noakes https://drewnoakes.com
32 */
33 @SuppressWarnings("WeakerAccess")
34 public class PsdHeaderDescriptor extends TagDescriptor<PsdHeaderDirectory>
35 {
36 public PsdHeaderDescriptor(@NotNull PsdHeaderDirectory directory)
37 {
38 super(directory);
39 }
40
41 @Override
42 public String getDescription(int tagType)
43 {
44 switch (tagType) {
45 case TAG_CHANNEL_COUNT:
46 return getChannelCountDescription();
47 case TAG_BITS_PER_CHANNEL:
48 return getBitsPerChannelDescription();
49 case TAG_COLOR_MODE:
50 return getColorModeDescription();
51 case TAG_IMAGE_HEIGHT:
52 return getImageHeightDescription();
53 case TAG_IMAGE_WIDTH:
54 return getImageWidthDescription();
55 default:
56 return super.getDescription(tagType);
57 }
58 }
59
60 @Nullable
61 public String getChannelCountDescription()
62 {
63 // Supported range is 1 to 56.
64 Integer value = _directory.getInteger(TAG_CHANNEL_COUNT);
65 if (value == null)
66 return null;
67 return value + " channel" + (value == 1 ? "" : "s");
68 }
69
70 @Nullable
71 public String getBitsPerChannelDescription()
72 {
73 // Supported values are 1, 8, 16 and 32.
74 Integer value = _directory.getInteger(TAG_BITS_PER_CHANNEL);
75 if (value == null)
76 return null;
77 return value + " bit" + (value == 1 ? "" : "s") + " per channel";
78 }
79
80 @Nullable
81 public String getColorModeDescription()
82 {
83 return getIndexedDescription(TAG_COLOR_MODE,
84 "Bitmap",
85 "Grayscale",
86 "Indexed",
87 "RGB",
88 "CMYK",
89 null,
90 null,
91 "Multichannel",
92 "Duotone",
93 "Lab");
94 }
95
96 @Nullable
97 public String getImageHeightDescription()
98 {
99 Integer value = _directory.getInteger(TAG_IMAGE_HEIGHT);
100 if (value == null)
101 return null;
102 return value + " pixel" + (value == 1 ? "" : "s");
103 }
104
105 @Nullable
106 public String getImageWidthDescription()
107 {
108 try {
109 Integer value = _directory.getInteger(TAG_IMAGE_WIDTH);
110 if (value == null)
111 return null;
112 return value + " pixel" + (value == 1 ? "" : "s");
113 } catch (Exception e) {
114 return null;
115 }
116 }
117 }