Class XMPScanner

java.lang.Object
com.twelvemonkeys.imageio.metadata.xmp.XMPScanner

public final class XMPScanner extends Object
XMPScanner
Version:
$Id: XMPScanner.java,v 1.0 Nov 11, 2009 4:49:00 PM haraldk Exp$
  • Field Details

    • XMP_PACKET_BEGIN

      private static final byte[] XMP_PACKET_BEGIN
      <?xpacket begin=

      • 8-bit (UTF-8): 0x3C 0x3F 0x78 0x70 0x61 0x63 0x6B 0x65 0x74 0x20 0x62 0x65 0x67 0x69 0x6E 0x3D
      • 16-bit encoding (UCS-2, UTF-16): (either big- or little-endian order) 0x3C 0x00 0x3F 0x00 0x78 0x00 0x70 0x00 0x61 0x00 0x63 0x00 0x6B 0x00 0x65 0x00 0x74 0x00 0x20 0x00 0x62 0x00 0x65 0x00 0x67 0x00 0x69 0x00 0x6E 0x00 0x3D [0x00]
      • 32-bit encoding (UCS-4): As 16 bit UCS2, with three 0x00 instead of one.

    • XMP_PACKET_END

      private static final byte[] XMP_PACKET_END
      <?xpacket end=
  • Constructor Details

    • XMPScanner

      public XMPScanner()
  • Method Details

    • scanForXMPPacket

      public static Reader scanForXMPPacket(Object pInput) throws IOException
      Scans the given input for an XML metadata packet. The scanning process involves reading every byte in the file, while searching for an XMP packet. This process is very inefficient, compared to reading a known file format.

      NOTE: The XMP Specification says this method of reading an XMP packet should be considered a last resort.
      This is because files may contain multiple XMP packets, some which may be related to embedded resources, some which may be obsolete (or even incomplete).

      Parameters:
      pInput - the input to scan. The input may be an ImageInputStream or any object that can be passed to ImageIO.createImageInputStream(Object). Typically this may be a File, InputStream or RandomAccessFile.
      Returns:
      a character Reader
      Throws:
      UnsupportedCharsetException - if the encoding specified within the BOM is not supported by the JRE.
      IOException - if an I/O exception occurs reading from pInput.
      See Also:
    • scanForSequence

      private static long scanForSequence(ImageInputStream pStream, byte[] pSequence) throws IOException
      Scans for a given ASCII sequence.
      Parameters:
      pStream - the stream to scan
      pSequence - the byte sequence to search for
      Returns:
      the start position of the given sequence.
      Throws:
      IOException - if an I/O exception occurs during scanning
    • main

      public static void main(String[] pArgs) throws IOException
      Throws:
      IOException