ImageLoaderFilter Class

DEPRECATED

com.bea.p13n.content.document.ref.loader
ImageLoaderFilter Class

public class ImageLoaderFilter

    extends Object
    implements com.bea.p13n.content.document.ref.loader.LoaderFilter

BulkLoader filter which can determine "width" and "height" metadata for GIF, JPEG, XBM, and PNG image files.

The image type is determined from the file name (based upon the MimeTypeHelper).

This class will generally not read in the entire contents of the file. It will instead attempt to get the metadata from the image format headers. However, it does not implement full decoders for the image formats, so, there might be images files for which this doesn't work.


Hierarchy
Object
  ImageLoaderFilter
All Implemented Interfaces

com.bea.p13n.content.document.ref.loader.LoaderFilter

Constructor Summary

ImageLoaderFilter()

 

Method Summary

public static void
handleGIF(File f, Properties p, BulkLoader loader)
Get the metadata for a GIF file.
public static void
handleJPEG(File f, Properties p, BulkLoader loader)
Get the metadata for a JPEG file.
public static void
handlePNG(File f, Properties p, BulkLoader loader)
Get the metadata for a PNG file.
public static void
handleXBM(File f, Properties p, BulkLoader loader)
Get the metadata for a XBM file.
public void
loadProperties(File f, Properties p, BulkLoader loader)
Fill out the properties with image metadata from the specified file.
public static void
main(String[] args)
Print the sizes of the files specified on the command-line.
public static int
toInt(byte b)
Safely convert a byte to an int (with high bytes set to 0).
 
Methods from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
   
Methods from interface com.bea.p13n.content.document.ref.loader.com.bea.p13n.content.document.ref.loader.LoaderFilter
loadProperties
 

Constructor Detail

ImageLoaderFilter

public ImageLoaderFilter()
 

Method Detail

handleGIF(File, Properties, BulkLoader) Method

public static void handleGIF(File f, 
                             Properties p, 
                             BulkLoader loader)
throws IOException
Get the metadata for a GIF file.

This will get "width" and "height".

This only supports standard GIF89a and GIF87a formats where the size is encoded in bytes 6-9 (i.e. after the 'GIF89a' header).

Exceptions

IOException

handleJPEG(File, Properties, BulkLoader) Method

public static void handleJPEG(File f, 
                              Properties p, 
                              BulkLoader loader)
throws IOException
Get the metadata for a JPEG file.

This will get "width" and "height".

This gets the size from the Start of Frame for Baseline DCT section (designated by the 0xff 0xc0 marker).

Exceptions

IOException

handlePNG(File, Properties, BulkLoader) Method

public static void handlePNG(File f, 
                             Properties p, 
                             BulkLoader loader)
throws IOException
Get the metadata for a PNG file.

This will get "width" and "height".

Exceptions

IOException

handleXBM(File, Properties, BulkLoader) Method

public static void handleXBM(File f, 
                             Properties p, 
                             BulkLoader loader)
throws IOException
Get the metadata for a XBM file.

This will get "width" and "height".

This uses a regular expression to find the width and height. It will ignore comments, although it won't ignore a width and height which are contained within a comments block.

Exceptions

IOException

loadProperties(File, Properties, BulkLoader) Method

public void loadProperties(File f, 
                           Properties p, 
                           BulkLoader loader)
Fill out the properties with image metadata from the specified file.

If the filename doesn't correspond to a GIF, JPEG, XBM, or PNG, it will be ignored.


main(String[]) Method

public static void main(String[] args)
throws Exception
Print the sizes of the files specified on the command-line.

Exceptions

Exception

toInt(byte) Method

public static int toInt(byte b)
Safely convert a byte to an int (with high bytes set to 0).