Class ImageIOExt


  • public class ImageIOExt
    extends Object
    Provides an alternative source of image input and output streams that uses optimized behavior.

    Currently implemented optimizations:

    Since:
    2.7.2
    Author:
    Andrea Aime - GeoSolutions
    • Constructor Detail

      • ImageIOExt

        public ImageIOExt()
    • Method Detail

      • getCacheDirectory

        public static File getCacheDirectory()
        Returns the cache directory used by ImageIOExt, either the manually configured one, or the result of calling ImageIO.getCacheDirectory()
      • setCacheDirectory

        public static void setCacheDirectory​(File cache)
        Sets the directory where cache files are to be created. If set to null (the default value) ImageIO.getCacheDirectory() will be used as the value
        Parameters:
        cache - a File specifying a directory.
      • setFilesystemThreshold

        public static void setFilesystemThreshold​(Long filesystemThreshold)
        Sets the memory/file usage threshold (or null to have the code fall back on ImageIO behavior)
        See Also:
        getFilesystemThreshold()
      • allowNativeCodec

        public static <T extends ImageReaderWriterSpi> void allowNativeCodec​(String format,
                                                                             Class<T> category,
                                                                             boolean allowed)
        Allows or disallows native acceleration for the specified image format. By default, the image I/O extension for JAI provides native acceleration for PNG and JPEG. Unfortunatly, those native codec has bug in their 1.0 version. Invoking this method will force the use of standard codec provided in J2SE 1.4.

        Implementation note: the current implementation assume that JAI codec class name start with "CLib". It work for Sun's 1.0 implementation, but may change in future versions. If this method doesn't recognize the class name, it does nothing.

        Parameters:
        format - The format name (e.g. "png").
        category - ImageReaderSpi.class to set the reader, or ImageWriterSpi.class to set the writer.
        allowed - false to disallow native acceleration.
      • isCLibAvailable

        public static boolean isCLibAvailable()
        Tells me whether or not the native libraries for JAI/ImageIO are active or not.
        Returns:
        false in case the JAI/ImageIO native libs are not in the path, true otherwise.
      • read

        public static RenderedImage read​(Object input)
                                  throws IOException
        Reads an image from the given input, working around some JDK reader issues. At the time of writing, this applies a work around for PNGs with RGB (no alpha) and a transparent color configured in the header, that the JDK reader cannot handle.
        Parameters:
        input - A non null image source, like a File, URL, or InputStream
        Returns:
        A image
        Throws:
        IOException