Class JPEGImageReader


  • public final class JPEGImageReader
    extends com.twelvemonkeys.imageio.ImageReaderBase
    A JPEG ImageReader implementation based on the JRE JPEGImageReader, that adds support and properly handles cases where the JRE version throws exceptions.
    Main features:
    • Support for YCbCr JPEGs without JFIF segment (converted to RGB, using the embedded ICC profile if applicable)
    • Support for CMYK JPEGs (converted to RGB by default or as CMYK, using the embedded ICC profile if applicable)
    • Support for Adobe YCCK JPEGs (converted to RGB by default or as CMYK, using the embedded ICC profile if applicable)
    • Support for JPEGs containing ICC profiles with interpretation other than 'Perceptual' (profile is assumed to be 'Perceptual' and used)
    • Support for JPEGs containing ICC profiles with class other than 'Display' (profile is assumed to have class 'Display' and used)
    • Support for JPEGs containing ICC profiles that are incompatible with stream data (image data is read, profile is ignored)
    • Support for JPEGs with corrupted ICC profiles (image data is read, profile is ignored)
    • Support for JPEGs with corrupted ICC_PROFILE segments (image data is read, profile is ignored)
    • Support for JPEGs using non-standard color spaces, unsupported by Java 2D (image data is read, profile is ignored)
    • Issues warnings instead of throwing exceptions in cases of corrupted data where ever the image data can still be read in a reasonable way
    Thumbnail support:
    • Support for JFIF thumbnails (even if stream contains inconsistent metadata)
    • Support for JFXX thumbnails (JPEG, Indexed and RGB)
    • Support for EXIF thumbnails (JPEG, RGB and YCbCr)
    Metadata support:
    • Support for JPEG metadata in both standard and native formats (even if stream contains inconsistent metadata)
    • Support for javax_imageio_jpeg_image_1.0 format (currently as native format, may change in the future)
    • Support for illegal combinations of JFIF, Exif and Adobe markers, using "unknown" segments in the "MarkerSequence" tag for the unsupported segments (for javax_imageio_jpeg_image_1.0 format)
    Version:
    $Id: JPEGImageReader.java,v 1.0 24.01.11 16.37 haraldk Exp$
    Author:
    Harald Kuhr, LUT-based YCbCR conversion by Werner Randelshofer, last modified by $Author: haraldk$
    • Field Summary

      • Fields inherited from class com.twelvemonkeys.imageio.ImageReaderBase

        imageInput
      • Fields inherited from class javax.imageio.ImageReader

        availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void abort()  
      boolean canReadRaster()  
      void dispose()  
      javax.imageio.ImageReadParam getDefaultReadParam()  
      java.lang.String getFormatName()  
      int getHeight​(int imageIndex)  
      javax.imageio.metadata.IIOMetadata getImageMetadata​(int imageIndex)  
      java.util.Iterator<javax.imageio.ImageTypeSpecifier> getImageTypes​(int imageIndex)  
      int getNumImages​(boolean allowSearch)  
      int getNumThumbnails​(int imageIndex)  
      javax.imageio.ImageTypeSpecifier getRawImageType​(int imageIndex)  
      javax.imageio.metadata.IIOMetadata getStreamMetadata()  
      int getThumbnailHeight​(int imageIndex, int thumbnailIndex)  
      int getThumbnailWidth​(int imageIndex, int thumbnailIndex)  
      int getWidth​(int imageIndex)  
      static void main​(java.lang.String[] args)  
      protected void processWarningOccurred​(java.lang.String warning)  
      java.awt.image.BufferedImage read​(int imageIndex, javax.imageio.ImageReadParam param)  
      java.awt.image.RenderedImage readAsRenderedImage​(int imageIndex, javax.imageio.ImageReadParam param)  
      boolean readerSupportsThumbnails()  
      java.awt.image.Raster readRaster​(int imageIndex, javax.imageio.ImageReadParam param)  
      java.awt.image.BufferedImage readThumbnail​(int imageIndex, int thumbnailIndex)  
      protected void resetMembers()  
      void setInput​(java.lang.Object input, boolean seekForwardOnly, boolean ignoreMetadata)  
      protected static void showIt​(java.awt.image.BufferedImage pImage, java.lang.String pTitle)  
      • Methods inherited from class com.twelvemonkeys.imageio.ImageReaderBase

        assertInput, checkBounds, fakeAOI, fakeSubsampling, getDestination, hasExplicitDestination, reset
      • Methods inherited from class javax.imageio.ImageReader

        abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, checkReadParamBandSettings, clearAbortRequest, computeRegions, getAspectRatio, getAvailableLocales, getImageMetadata, getInput, getLocale, getMinIndex, getOriginatingProvider, getSourceRegion, getStreamMetadata, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, hasThumbnails, isIgnoringMetadata, isImageTiled, isRandomAccessEasy, isSeekForwardOnly, processImageComplete, processImageProgress, processImageStarted, processImageUpdate, processPassComplete, processPassStarted, processReadAborted, processSequenceComplete, processSequenceStarted, processThumbnailComplete, processThumbnailPassComplete, processThumbnailPassStarted, processThumbnailProgress, processThumbnailStarted, processThumbnailUpdate, processWarningOccurred, read, readAll, readAll, readTile, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, setInput, setInput, setLocale
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • resetMembers

        protected void resetMembers()
        Specified by:
        resetMembers in class com.twelvemonkeys.imageio.ImageReaderBase
      • dispose

        public void dispose()
        Overrides:
        dispose in class com.twelvemonkeys.imageio.ImageReaderBase
      • getFormatName

        public java.lang.String getFormatName()
                                       throws java.io.IOException
        Overrides:
        getFormatName in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • getWidth

        public int getWidth​(int imageIndex)
                     throws java.io.IOException
        Specified by:
        getWidth in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • getHeight

        public int getHeight​(int imageIndex)
                      throws java.io.IOException
        Specified by:
        getHeight in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • getImageTypes

        public java.util.Iterator<javax.imageio.ImageTypeSpecifier> getImageTypes​(int imageIndex)
                                                                           throws java.io.IOException
        Specified by:
        getImageTypes in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • getRawImageType

        public javax.imageio.ImageTypeSpecifier getRawImageType​(int imageIndex)
                                                         throws java.io.IOException
        Overrides:
        getRawImageType in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • read

        public java.awt.image.BufferedImage read​(int imageIndex,
                                                 javax.imageio.ImageReadParam param)
                                          throws java.io.IOException
        Specified by:
        read in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • setInput

        public void setInput​(java.lang.Object input,
                             boolean seekForwardOnly,
                             boolean ignoreMetadata)
        Overrides:
        setInput in class com.twelvemonkeys.imageio.ImageReaderBase
      • getNumImages

        public int getNumImages​(boolean allowSearch)
                         throws java.io.IOException
        Overrides:
        getNumImages in class com.twelvemonkeys.imageio.ImageReaderBase
        Throws:
        java.io.IOException
      • canReadRaster

        public boolean canReadRaster()
        Overrides:
        canReadRaster in class javax.imageio.ImageReader
      • readRaster

        public java.awt.image.Raster readRaster​(int imageIndex,
                                                javax.imageio.ImageReadParam param)
                                         throws java.io.IOException
        Overrides:
        readRaster in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • readAsRenderedImage

        public java.awt.image.RenderedImage readAsRenderedImage​(int imageIndex,
                                                                javax.imageio.ImageReadParam param)
                                                         throws java.io.IOException
        Overrides:
        readAsRenderedImage in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • abort

        public void abort()
        Overrides:
        abort in class javax.imageio.ImageReader
      • getDefaultReadParam

        public javax.imageio.ImageReadParam getDefaultReadParam()
        Overrides:
        getDefaultReadParam in class javax.imageio.ImageReader
      • readerSupportsThumbnails

        public boolean readerSupportsThumbnails()
        Overrides:
        readerSupportsThumbnails in class javax.imageio.ImageReader
      • getNumThumbnails

        public int getNumThumbnails​(int imageIndex)
                             throws java.io.IOException
        Overrides:
        getNumThumbnails in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • getThumbnailWidth

        public int getThumbnailWidth​(int imageIndex,
                                     int thumbnailIndex)
                              throws java.io.IOException
        Overrides:
        getThumbnailWidth in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • getThumbnailHeight

        public int getThumbnailHeight​(int imageIndex,
                                      int thumbnailIndex)
                               throws java.io.IOException
        Overrides:
        getThumbnailHeight in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • readThumbnail

        public java.awt.image.BufferedImage readThumbnail​(int imageIndex,
                                                          int thumbnailIndex)
                                                   throws java.io.IOException
        Overrides:
        readThumbnail in class javax.imageio.ImageReader
        Throws:
        java.io.IOException
      • getImageMetadata

        public javax.imageio.metadata.IIOMetadata getImageMetadata​(int imageIndex)
                                                            throws java.io.IOException
        Overrides:
        getImageMetadata in class com.twelvemonkeys.imageio.ImageReaderBase
        Throws:
        java.io.IOException
      • getStreamMetadata

        public javax.imageio.metadata.IIOMetadata getStreamMetadata()
                                                             throws java.io.IOException
        Overrides:
        getStreamMetadata in class com.twelvemonkeys.imageio.ImageReaderBase
        Throws:
        java.io.IOException
      • processWarningOccurred

        protected void processWarningOccurred​(java.lang.String warning)
        Overrides:
        processWarningOccurred in class javax.imageio.ImageReader
      • showIt

        protected static void showIt​(java.awt.image.BufferedImage pImage,
                                     java.lang.String pTitle)
      • main

        public static void main​(java.lang.String[] args)
                         throws java.io.IOException
        Throws:
        java.io.IOException