File: PhotoshopDirectory.java

package info (click to toggle)
libmetadata-extractor-java 2.6.4-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 4,124 kB
  • ctags: 2,408
  • sloc: java: 15,158; xml: 110; sh: 93; makefile: 18
file content (161 lines) | stat: -rw-r--r-- 8,817 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
 * Copyright 2002-2012 Drew Noakes
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 *
 * More information about this project is available at:
 *
 *    http://drewnoakes.com/code/exif/
 *    http://code.google.com/p/metadata-extractor/
 */

package com.drew.metadata.photoshop;

import com.drew.lang.annotations.NotNull;
import com.drew.lang.annotations.Nullable;
import com.drew.metadata.Directory;

import java.util.HashMap;

/**
 * Holds the metadata found in the APPD segment of a JPEG file saved by Photoshop.
 *
 * @author Yuri Binev, Drew Noakes http://drewnoakes.com
 */
public class PhotoshopDirectory extends Directory
{
    public static final int TAG_PHOTOSHOP_CHANNELS_ROWS_COLUMNS_DEPTH_MODE = 0x03E8;
    public static final int TAG_PHOTOSHOP_MAC_PRINT_INFO = 0x03E9;
    public static final int TAG_PHOTOSHOP_XML = 0x03EA;
    public static final int TAG_PHOTOSHOP_INDEXED_COLOR_TABLE = 0x03EB;
    public static final int TAG_PHOTOSHOP_RESOLUTION_INFO = 0x03ED;
    public static final int TAG_PHOTOSHOP_ALPHA_CHANNELS = 0x03EE;
    public static final int TAG_PHOTOSHOP_DISPLAY_INFO = 0x03EF;
    public static final int TAG_PHOTOSHOP_CAPTION = 0x03F0;
    public static final int TAG_PHOTOSHOP_BORDER_INFORMATION = 0x03F1;
    public static final int TAG_PHOTOSHOP_BACKGROUND_COLOR = 0x03F2;
    public static final int TAG_PHOTOSHOP_PRINT_FLAGS = 0x03F3;
    public static final int TAG_PHOTOSHOP_GRAYSCALE_AND_MULTICHANNEL_HALFTONING_INFORMATION = 0x03F4;
    public static final int TAG_PHOTOSHOP_COLOR_HALFTONING_INFORMATION = 0x03F5;
    public static final int TAG_PHOTOSHOP_DUOTONE_HALFTONING_INFORMATION = 0x03F6;
    public static final int TAG_PHOTOSHOP_GRAYSCALE_AND_MULTICHANNEL_TRANSFER_FUNCTION = 0x03F7;
    public static final int TAG_PHOTOSHOP_COLOR_TRANSFER_FUNCTIONS = 0x03F8;
    public static final int TAG_PHOTOSHOP_DUOTONE_TRANSFER_FUNCTIONS = 0x03F9;
    public static final int TAG_PHOTOSHOP_DUOTONE_IMAGE_INFORMATION = 0x03FA;
    public static final int TAG_PHOTOSHOP_EFFECTIVE_BLACK_AND_WHITE_VALUES = 0x03FB;
    public static final int TAG_PHOTOSHOP_EPS_OPTIONS = 0x03FD;
    public static final int TAG_PHOTOSHOP_QUICK_MASK_INFORMATION = 0x03FE;
    public static final int TAG_PHOTOSHOP_LAYER_STATE_INFORMATION = 0x0400;
    public static final int TAG_PHOTOSHOP_LAYERS_GROUP_INFORMATION = 0x0402;
    public static final int TAG_PHOTOSHOP_IPTC = 0x0404;
    public static final int TAG_PHOTOSHOP_IMAGE_MODE_FOR_RAW_FORMAT_FILES = 0x0405;
    public static final int TAG_PHOTOSHOP_JPEG_QUALITY = 0x0406;
    public static final int TAG_PHOTOSHOP_GRID_AND_GUIDES_INFORMATION = 0x0408;
    public static final int TAG_PHOTOSHOP_THUMBNAIL_OLD = 0x0409;
    public static final int TAG_PHOTOSHOP_COPYRIGHT = 0x040A;
    public static final int TAG_PHOTOSHOP_URL = 0x040B;
    public static final int TAG_PHOTOSHOP_THUMBNAIL = 0x040C;
    public static final int TAG_PHOTOSHOP_GLOBAL_ANGLE = 0x040D;
    public static final int TAG_PHOTOSHOP_ICC_UNTAGGED_PROFILE = 0x0411;
    public static final int TAG_PHOTOSHOP_SEED_NUMBER = 0x0414;
    public static final int TAG_PHOTOSHOP_GLOBAL_ALTITUDE = 0x0419;
    public static final int TAG_PHOTOSHOP_SLICES = 0x041A;
    public static final int TAG_PHOTOSHOP_URL_LIST = 0x041E;
    public static final int TAG_PHOTOSHOP_VERSION = 0x0421;
    public static final int TAG_PHOTOSHOP_CAPTION_DIGEST = 0x0425;
    public static final int TAG_PHOTOSHOP_PRINT_SCALE = 0x0426;
    public static final int TAG_PHOTOSHOP_PIXEL_ASPECT_RATIO = 0x0428;
    public static final int TAG_PHOTOSHOP_PRINT_INFO = 0x042F;
    public static final int TAG_PHOTOSHOP_PRINT_FLAGS_INFO = 0x2710;

    @NotNull
    protected static final HashMap<Integer, String> _tagNameMap = new HashMap<Integer, String>();

    static {
        _tagNameMap.put(TAG_PHOTOSHOP_CHANNELS_ROWS_COLUMNS_DEPTH_MODE, "Channels, Rows, Columns, Depth, Mode");
        _tagNameMap.put(TAG_PHOTOSHOP_MAC_PRINT_INFO, "Mac Print Info");
        _tagNameMap.put(TAG_PHOTOSHOP_XML, "XML Data");
        _tagNameMap.put(TAG_PHOTOSHOP_INDEXED_COLOR_TABLE, "Indexed Color Table");
        _tagNameMap.put(TAG_PHOTOSHOP_RESOLUTION_INFO, "Resolution Info");
        _tagNameMap.put(TAG_PHOTOSHOP_ALPHA_CHANNELS, "Alpha Channels");
        _tagNameMap.put(TAG_PHOTOSHOP_DISPLAY_INFO, "Display Info");
        _tagNameMap.put(TAG_PHOTOSHOP_CAPTION, "Caption");
        _tagNameMap.put(TAG_PHOTOSHOP_BORDER_INFORMATION, "Border Information");
        _tagNameMap.put(TAG_PHOTOSHOP_BACKGROUND_COLOR, "Background Color");
        _tagNameMap.put(TAG_PHOTOSHOP_PRINT_FLAGS, "Print Flags");
        _tagNameMap.put(TAG_PHOTOSHOP_GRAYSCALE_AND_MULTICHANNEL_HALFTONING_INFORMATION, "Grayscale and Multichannel Halftoning Information");
        _tagNameMap.put(TAG_PHOTOSHOP_COLOR_HALFTONING_INFORMATION, "Color Halftoning Information");
        _tagNameMap.put(TAG_PHOTOSHOP_DUOTONE_HALFTONING_INFORMATION, "Duotone Halftoning Information");
        _tagNameMap.put(TAG_PHOTOSHOP_GRAYSCALE_AND_MULTICHANNEL_TRANSFER_FUNCTION, "Grayscale and Multichannel Transfer Function");
        _tagNameMap.put(TAG_PHOTOSHOP_COLOR_TRANSFER_FUNCTIONS, "Color Transfer Functions");
        _tagNameMap.put(TAG_PHOTOSHOP_DUOTONE_TRANSFER_FUNCTIONS, "Duotone Transfer Functions");
        _tagNameMap.put(TAG_PHOTOSHOP_DUOTONE_IMAGE_INFORMATION, "Duotone Image Information");
        _tagNameMap.put(TAG_PHOTOSHOP_EFFECTIVE_BLACK_AND_WHITE_VALUES, "Effective Black and White Values");
        _tagNameMap.put(TAG_PHOTOSHOP_EPS_OPTIONS, "EPS Options");
        _tagNameMap.put(TAG_PHOTOSHOP_QUICK_MASK_INFORMATION, "Quick Mask Information");
        _tagNameMap.put(TAG_PHOTOSHOP_LAYER_STATE_INFORMATION, "Layer State Information");
        _tagNameMap.put(TAG_PHOTOSHOP_LAYERS_GROUP_INFORMATION, "Layers Group Information");
        _tagNameMap.put(TAG_PHOTOSHOP_IPTC, "IPTC-NAA Record");
        _tagNameMap.put(TAG_PHOTOSHOP_IMAGE_MODE_FOR_RAW_FORMAT_FILES, "Image Mode for Raw Format Files");
        _tagNameMap.put(TAG_PHOTOSHOP_JPEG_QUALITY, "JPEG Quality");
        _tagNameMap.put(TAG_PHOTOSHOP_GRID_AND_GUIDES_INFORMATION, "Grid and Guides Information");
        _tagNameMap.put(TAG_PHOTOSHOP_THUMBNAIL_OLD, "Photoshop 4.0 Thumbnail");
        _tagNameMap.put(TAG_PHOTOSHOP_COPYRIGHT, "Copyright Flag");
        _tagNameMap.put(TAG_PHOTOSHOP_URL, "URL");
        _tagNameMap.put(TAG_PHOTOSHOP_THUMBNAIL, "Thumbnail Data");
        _tagNameMap.put(TAG_PHOTOSHOP_GLOBAL_ANGLE, "Global Angle");
        _tagNameMap.put(TAG_PHOTOSHOP_ICC_UNTAGGED_PROFILE, "ICC Untagged Profile");
        _tagNameMap.put(TAG_PHOTOSHOP_SEED_NUMBER, "Seed Number");
        _tagNameMap.put(TAG_PHOTOSHOP_GLOBAL_ALTITUDE, "Global Altitude");
        _tagNameMap.put(TAG_PHOTOSHOP_SLICES, "Slices");
        _tagNameMap.put(TAG_PHOTOSHOP_URL_LIST, "URL List");
        _tagNameMap.put(TAG_PHOTOSHOP_VERSION, "Version Info");
        _tagNameMap.put(TAG_PHOTOSHOP_CAPTION_DIGEST, "Caption Digest");
        _tagNameMap.put(TAG_PHOTOSHOP_PRINT_SCALE, "Print Scale");
        _tagNameMap.put(TAG_PHOTOSHOP_PIXEL_ASPECT_RATIO, "Pixel Aspect Ratio");
        _tagNameMap.put(TAG_PHOTOSHOP_PRINT_INFO, "Print Info");
        _tagNameMap.put(TAG_PHOTOSHOP_PRINT_FLAGS_INFO, "Print Flags Information");
    }

    public PhotoshopDirectory()
    {
        this.setDescriptor(new PhotoshopDescriptor(this));
    }

    @NotNull
    public String getName()
    {
        return "Photoshop";
    }

    @NotNull
    protected HashMap<Integer, String> getTagNameMap()
    {
        return _tagNameMap;
    }

    @Nullable
    public byte[] getThumbnailBytes()
    {
        byte[] storedBytes = getByteArray(PhotoshopDirectory.TAG_PHOTOSHOP_THUMBNAIL);
        if (storedBytes == null)
            storedBytes = getByteArray(PhotoshopDirectory.TAG_PHOTOSHOP_THUMBNAIL_OLD);
        if (storedBytes == null)
            return null;

        int thumbSize = storedBytes.length - 28;
        byte[] thumbBytes = new byte[thumbSize];
        System.arraycopy(storedBytes, 28, thumbBytes, 0, thumbSize);
        return thumbBytes;
    }
}