Class JPEGMetadataReader

java.lang.Object
is.galia.codec.jpeg.JPEGMetadataReader

public final class JPEGMetadataReader extends Object

Reads various metadata from a JPEG image.

This is far from a comprehensive reader—essentially it is a grab bag of functionality needed by various application components and plugins.

See Also:
  • Constructor Details

    • JPEGMetadataReader

      public JPEGMetadataReader()
  • Method Details

    • getColorTransform

      public JPEGMetadataReader.AdobeColorTransform getColorTransform() throws IOException
      Returns:
      Color transform from the APP14 segment.
      Throws:
      IOException
    • getEXIF

      public byte[] getEXIF() throws IOException
      Returns:
      EXIF data from the APP1 segment.
      Throws:
      IOException
    • getEXIFOffset

      public int getEXIFOffset() throws IOException
      Returns:
      Offset of the EXIF IFD relative to the start of the stream, or -1 if there is no EXIF IFD.
      Throws:
      IOException
    • getICCProfile

      public ICC_Profile getICCProfile() throws IOException

      Reads an embedded ICC profile from an APP2 segment.

      N.B.: ICC profiles can also be extracted from IIOMetadata objects, but as of JDK 11, the JDK Image I/O JPEG reader does not support JPEGs with CMYK color and will throw an exception before the metadata can be read.

      Returns:
      ICC profile, or null if one is not contained in the stream.
      Throws:
      IOException
      See Also:
    • getIPTC

      public byte[] getIPTC() throws IOException
      Returns:
      IPTC data from the APP13 segment.
      Throws:
      IOException
    • getWidth

      public int getWidth() throws IOException
      Throws:
      IOException
    • getHeight

      public int getHeight() throws IOException
      Throws:
      IOException
    • getThumbnailCompression

      public int getThumbnailCompression() throws IOException
      Returns:
      Thumbnail compression value from EXIF data, or -1 if there is no thumbnail.
      Throws:
      IOException
    • getThumbnailData

      public byte[] getThumbnailData() throws IOException
      Returns:
      Raw embedded thumbnail data from EXIF data, if available.
      Throws:
      IOException
      See Also:
    • getXMP

      public String getXMP() throws IOException
      Returns:
      Fully formed XMP tree from one or more APP1 segments. rdf:RDF is the outermost element and some properties (especially large ones) may be removed.
      Throws:
      IOException
    • hasAdobeSegment

      public boolean hasAdobeSegment() throws IOException
      Throws:
      IOException
    • isProgressive

      public boolean isProgressive() throws IOException
      Throws:
      IOException
    • setSource

      public void setSource(ImageInputStream inputStream)
      Parameters:
      inputStream - Fresh stream from which to read the image.