PageRenderTime 85ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/Source/com/drew/metadata/photoshop/PhotoshopDirectory.java

http://metadata-extractor.googlecode.com/
Java | 136 lines | 102 code | 12 blank | 22 comment | 4 complexity | ecdcc4f96d121a507c708340183c1244 MD5 | raw file
Possible License(s): Apache-2.0
  1. /*
  2. * Copyright 2002-2011 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. * http://drewnoakes.com/code/exif/
  19. * http://code.google.com/p/metadata-extractor/
  20. */
  21. package com.drew.metadata.photoshop;
  22. import com.drew.lang.annotations.NotNull;
  23. import com.drew.lang.annotations.Nullable;
  24. import com.drew.metadata.Directory;
  25. import java.util.HashMap;
  26. /** @author Yuri Binev, Drew Noakes http://drewnoakes.com */
  27. public class PhotoshopDirectory extends Directory
  28. {
  29. public static final int TAG_PHOTOSHOP_THUMBNAIL = 0x040C;
  30. public static final int TAG_PHOTOSHOP_THUMBNAIL_OLD = 0x0409;
  31. public static final int TAG_PHOTOSHOP_JPEG_QUALITY = 0x0406;
  32. public static final int TAG_PHOTOSHOP_URL = 0x040B;
  33. public static final int TAG_PHOTOSHOP_IPTC = 0x0404;
  34. public static final int TAG_PHOTOSHOP_CAPTION_DIGEST = 0x0425;
  35. public static final int TAG_PHOTOSHOP_SLICES = 0x041a;
  36. public static final int TAG_PHOTOSHOP_VERSION = 0x0421;
  37. public static final int TAG_PHOTOSHOP_RESOLUTION_INFO = 0x03ed;
  38. public static final int TAG_PHOTOSHOP_XML = 0x03EA;
  39. public static final int TAG_PHOTOSHOP_COPYRIGHT = 0x040A;
  40. public static final int TAG_PHOTOSHOP_GLOBAL_ANGLE = 0x040D;
  41. public static final int TAG_PHOTOSHOP_GLOBAL_ALTITUDE = 0x0419;
  42. public static final int TAG_PHOTOSHOP_URL_LIST = 0x041E;
  43. public static final int TAG_PHOTOSHOP_PRINT_SCALE = 0x0426;
  44. public static final int TAG_PHOTOSHOP_PRINT_FLAGS_INFO = 0x2710;
  45. public static final int TAG_PHOTOSHOP_PRINT_FLAGS = 0x03F3;
  46. public static final int TAG_PHOTOSHOP_SEED_NUMBER = 0x0414;
  47. public static final int TAG_PHOTOSHOP_PIXEL_ASPECT_RATIO = 0x0428;
  48. @NotNull
  49. protected static final HashMap<Integer, String> _tagNameMap = new HashMap<Integer, String>();
  50. static {
  51. // TODO create fields for the numeric tags below
  52. _tagNameMap.put(TAG_PHOTOSHOP_THUMBNAIL, "Thumbnail Data");
  53. _tagNameMap.put(TAG_PHOTOSHOP_URL, "URL");
  54. _tagNameMap.put(TAG_PHOTOSHOP_IPTC, "IPTC-NAA record");
  55. _tagNameMap.put(TAG_PHOTOSHOP_CAPTION_DIGEST, "Caption digest");
  56. _tagNameMap.put(TAG_PHOTOSHOP_SLICES, "Slices");
  57. _tagNameMap.put(TAG_PHOTOSHOP_VERSION, "Version Info");
  58. _tagNameMap.put(0x03E9, "Mac Print info");
  59. _tagNameMap.put(TAG_PHOTOSHOP_XML, "XML Data");
  60. _tagNameMap.put(0x042F, "Print info");
  61. _tagNameMap.put(TAG_PHOTOSHOP_RESOLUTION_INFO, "Resolution Info");
  62. _tagNameMap.put(TAG_PHOTOSHOP_PRINT_FLAGS, "Print Flags");
  63. _tagNameMap.put(0x03E8, "Channels, rows, columns, depth, mode");
  64. _tagNameMap.put(0x03EB, "Indexed color table");
  65. _tagNameMap.put(0x03EE, "Alpha channels");
  66. _tagNameMap.put(0x03EF, "DisplayInfo");
  67. _tagNameMap.put(0x03F0, "Caption");
  68. _tagNameMap.put(0x03F1, "Border information");
  69. _tagNameMap.put(0x03F2, "Background color");
  70. _tagNameMap.put(0x03F3, "Print flags");
  71. _tagNameMap.put(0x03F4, "Grayscale and multichannel halftoning information");
  72. _tagNameMap.put(0x03F5, "Color halftoning information");
  73. _tagNameMap.put(0x03F6, "Duotone halftoning information");
  74. _tagNameMap.put(0x03F7, "Grayscale and multichannel transfer function");
  75. _tagNameMap.put(0x03F8, "Color transfer functions");
  76. _tagNameMap.put(0x03F9, "Duotone transfer functions");
  77. _tagNameMap.put(0x03FA, "Duotone image information");
  78. _tagNameMap.put(0x03FB, "Effective black and white values");
  79. _tagNameMap.put(0x03FD, "EPS options");
  80. _tagNameMap.put(0x03FE, "Quick Mask information");
  81. _tagNameMap.put(0x0400, "Layer state information");
  82. _tagNameMap.put(0x0402, "Layers group information");
  83. _tagNameMap.put(0x0405, "Image mode for raw format files");
  84. _tagNameMap.put(TAG_PHOTOSHOP_JPEG_QUALITY, "JPEG quality");
  85. _tagNameMap.put(0x0408, "Grid and guides information");
  86. _tagNameMap.put(0x0411, "ICC Untagged Profile");
  87. _tagNameMap.put(TAG_PHOTOSHOP_THUMBNAIL_OLD, "Photoshop 4.0 Thumbnail");
  88. _tagNameMap.put(TAG_PHOTOSHOP_COPYRIGHT, "Copyright flag");
  89. _tagNameMap.put(TAG_PHOTOSHOP_GLOBAL_ANGLE, "Global Angle");
  90. _tagNameMap.put(TAG_PHOTOSHOP_GLOBAL_ALTITUDE, "Global Altitude");
  91. _tagNameMap.put(TAG_PHOTOSHOP_PRINT_FLAGS_INFO, "Print flags information");
  92. _tagNameMap.put(TAG_PHOTOSHOP_PRINT_SCALE, "Print Scale");
  93. _tagNameMap.put(TAG_PHOTOSHOP_URL_LIST, "URL List");
  94. _tagNameMap.put(TAG_PHOTOSHOP_PIXEL_ASPECT_RATIO, "Pixel Aspect Ratio");
  95. _tagNameMap.put(TAG_PHOTOSHOP_SEED_NUMBER, "Seed number");
  96. }
  97. public PhotoshopDirectory()
  98. {
  99. this.setDescriptor(new PhotoshopDescriptor(this));
  100. }
  101. @NotNull
  102. public String getName()
  103. {
  104. return "Photoshop";
  105. }
  106. @NotNull
  107. protected HashMap<Integer, String> getTagNameMap()
  108. {
  109. return _tagNameMap;
  110. }
  111. @Nullable
  112. public byte[] getThumbnailBytes()
  113. {
  114. byte[] storedBytes = getByteArray(PhotoshopDirectory.TAG_PHOTOSHOP_THUMBNAIL);
  115. if (storedBytes == null)
  116. storedBytes = getByteArray(PhotoshopDirectory.TAG_PHOTOSHOP_THUMBNAIL_OLD);
  117. if (storedBytes == null)
  118. return null;
  119. int thumbSize = storedBytes.length - 28;
  120. byte[] thumbBytes = new byte[thumbSize];
  121. System.arraycopy(storedBytes, 28, thumbBytes, 0, thumbSize);
  122. return thumbBytes;
  123. }
  124. }