Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.flexstor.flexdbserver.services.asset.iptc
Class PSDParser  view PSDParser download PSDParser.java

java.lang.Object
  extended bycom.flexstor.flexdbserver.services.asset.iptc.IPTCParser
      extended bycom.flexstor.flexdbserver.services.asset.iptc.PSDParser
All Implemented Interfaces:
IIPTCParser

public class PSDParser
extends IPTCParser
implements IIPTCParser

The PSDParser is used to parse header information for an Adobe Photoshop Document (PSD File).

Version:
initial

Field Summary
private  byte[] abImageResourceSection
          This is an array of bytes which consists of the entire Image Resource Section (i.e.
private  com.flexstor.common.io.xfile.FlexXRandomAccessFile fPSDFile
          The file we will parse.
private  java.util.Hashtable hImageResourceBlockHash
          I think the Image Resource Block data would go nicely in a Hashtable because there may be more than one Image Resource Block in a file and we would really only care about the 2-byte ID and the N-byte Resource Data (where N is always an even number)
private  int nBitsPerChannel
          The number of bits per channel.
private  int nChannels
          The number of channels in the image, including any alpha channels.
private  int nColorMode
          The color mode of the file.
private  int nColorModeDataLength
          The length of the color data.
private  int nColumns
          The width of the image in pixels.
private  int nImageResourcesLength
          nImageResourcesLength is the total length of all Image Resource Blocks.
private  int nRows
          The height of the image in pixels.
private  java.lang.String sSignature
          The "signature" of a PSD file is always equal to "8BPS" The format of a Photoshop file is described in a document titled "Photoshop File Formats.pdf" and is available on the Adobe site.
 
Fields inherited from class com.flexstor.flexdbserver.services.asset.iptc.IPTCParser
hDataSets
 
Constructor Summary
PSDParser(com.flexstor.common.io.xfile.FlexXFile fInputFile)
          Creates new PSDParser from the File parameter passed in.
 
Method Summary
protected  void closeFile()
           
 int getBitsPerChannel()
          Obtain the number of bits per channel.
 int getColorMode()
          Obtain the color mode of the file.
 java.lang.String getDatasetValue(java.lang.String sDatasetID)
          Obtain the value for the specified Dataset number.
 int getHeight()
          Obtain the height of the image.
 byte[] getImageResource(int nResourceID)
          Obtain a specific Image Resource Data Block of the file.
 byte[] getIPTCNAArecord()
          Obtain the IPTC-NAA Record of the file.
 int getNumberOfChannels()
          Obtain the number of channels in the image.
 int getWidth()
          Obtain the width of the image.
 boolean parseFile()
          Parse a PSD (Photoshop) file.
private  boolean parseImageResourceBlocks()
          This method parses the entire Image Resource Section byte array into separate Image Resource Blocks and places them in the hIRBhashtable.
 
Methods inherited from class com.flexstor.flexdbserver.services.asset.iptc.IPTCParser
BGPDebug, BGPError, hexBytesToInt, parseIPTCdata
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fPSDFile

private com.flexstor.common.io.xfile.FlexXRandomAccessFile fPSDFile
The file we will parse. It is a RandomAccessFile so we can skip unimportant parts of the file.


sSignature

private java.lang.String sSignature
The "signature" of a PSD file is always equal to "8BPS" The format of a Photoshop file is described in a document titled "Photoshop File Formats.pdf" and is available on the Adobe site.


nChannels

private int nChannels
The number of channels in the image, including any alpha channels. Supported range is 1 to 24.


nRows

private int nRows
The height of the image in pixels. Supported range is 1 to 30,000.


nColumns

private int nColumns
The width of the image in pixels. Supported range is 1 to 30,000.


nBitsPerChannel

private int nBitsPerChannel
The number of bits per channel. Supported values are 1, 8, and 16.


nColorMode

private int nColorMode
The color mode of the file. Supported values are: Bitmap=0; Grayscale=1; Indexed=2; RGB=3; CMYK=4; Multichannel=7; Duotone=8; Lab=9.


nColorModeDataLength

private int nColorModeDataLength
The length of the color data. Only indexed color and duotone have color mode data. For all other modes, this will be just four bytes of 0.


nImageResourcesLength

private int nImageResourcesLength
nImageResourcesLength is the total length of all Image Resource Blocks.


abImageResourceSection

private byte[] abImageResourceSection
This is an array of bytes which consists of the entire Image Resource Section (i.e. several individual Image Resource Blocks)


hImageResourceBlockHash

private java.util.Hashtable hImageResourceBlockHash
I think the Image Resource Block data would go nicely in a Hashtable because there may be more than one Image Resource Block in a file and we would really only care about the 2-byte ID and the N-byte Resource Data (where N is always an even number)

Constructor Detail

PSDParser

public PSDParser(com.flexstor.common.io.xfile.FlexXFile fInputFile)
Creates new PSDParser from the File parameter passed in.

Method Detail

parseFile

public boolean parseFile()
Parse a PSD (Photoshop) file. In order to return true, the file must have a valid PSD file from which we can retrieve IPTC-NAA info. This may or may not parse the IPTC-NAA data as well. (Right now I'm leaning towards doing it.)

Specified by:
parseFile in interface IIPTCParser

closeFile

protected void closeFile()

parseImageResourceBlocks

private boolean parseImageResourceBlocks()
This method parses the entire Image Resource Section byte array into separate Image Resource Blocks and places them in the hIRBhashtable.


getNumberOfChannels

public int getNumberOfChannels()
Obtain the number of channels in the image.


getHeight

public int getHeight()
Obtain the height of the image.


getWidth

public int getWidth()
Obtain the width of the image.


getBitsPerChannel

public int getBitsPerChannel()
Obtain the number of bits per channel. Should be either 1, 8, or 16.


getColorMode

public int getColorMode()
Obtain the color mode of the file.
Value should be one of the following:
   0 is Bitmap
   1 is Grayscale
   2 is Indexed
   3 is RGB
   4 is CMYK
   7 is Multichannel
   8 is Duotone
   9 is Lab


getImageResource

public byte[] getImageResource(int nResourceID)
Obtain a specific Image Resource Data Block of the file.


getIPTCNAArecord

public byte[] getIPTCNAArecord()
Obtain the IPTC-NAA Record of the file.


getDatasetValue

public java.lang.String getDatasetValue(java.lang.String sDatasetID)
Obtain the value for the specified Dataset number.

Specified by:
getDatasetValue in interface IIPTCParser