Package org.esa.snap.core.util.geotiff
Class IIOUtils
java.lang.Object
org.esa.snap.core.util.geotiff.IIOUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic ImageWritergetImageWriter(ImageTypeSpecifier imageType, String imageFormatName) Gets an image writer suitable to be used for the given image type and image format.static ImageWritergetImageWriter(ImageTypeSpecifier imageType, String imageFormatName, String metadataFormatName) Gets an image writer suitable to be used for the given image type, image format and metadata format.static StringgetXML(IIOMetadata metadata) static IIOImageReturns aBufferedImageas the result of decoding a suppliedFilewith anImageReaderchosen automatically from among those currently registered.static IIOImagereadImage(ImageInputStream stream) Returns aBufferedImageas the result of decoding a suppliedImageInputStreamwith anImageReaderchosen automatically from among those currently registered.static booleanwriteImage(IIOImage iioImage, String formatName, File output) Writes an image using an arbitraryImageWriterthat supports the given format to aFile.static booleanwriteImage(IIOImage iioImage, String formatName, ImageOutputStream output) Writes an image using the an arbitraryImageWriterthat supports the given format to anImageOutputStream.
-
Method Details
-
readImage
Returns aBufferedImageas the result of decoding a suppliedFilewith anImageReaderchosen automatically from among those currently registered. TheFileis wrapped in anImageInputStream. If no registeredImageReaderclaims to be able to readImage the resulting stream,nullis returned.The current cache settings from
getUseCacheandgetCacheDirectorywill be used to control caching in theImageInputStreamthat is created.Note that there is no
readImagemethod that takes a filename as aString; use this method instead after creating aFilefrom the filename.This methods does not attempt to locate
ImageReaders that can readImage directly from aFile; that may be accomplished usingIIORegistryandImageReaderSpi.- Parameters:
input- aFileto readImage from.- Returns:
- a
BufferedImagecontaining the decoded contents of the input, ornull. - Throws:
IllegalArgumentException- ifinputisnull.IOException- if an error occurs during reading.
-
readImage
Returns aBufferedImageas the result of decoding a suppliedImageInputStreamwith anImageReaderchosen automatically from among those currently registered. If no registeredImageReaderclaims to be able to readImage the stream,nullis returned.- Parameters:
stream- anImageInputStreamto readImage from.- Returns:
- a
BufferedImagecontaining the decoded contents of the input, ornull. - Throws:
IllegalArgumentException- ifstreamisnull.IOException- if an error occurs during reading.
-
writeImage
public static boolean writeImage(IIOImage iioImage, String formatName, File output) throws IOException Writes an image using an arbitraryImageWriterthat supports the given format to aFile. If there is already aFilepresent, its contents are discarded.- Parameters:
iioImage- the image data to be written.formatName- aStringcontaing the informal name of the format.output- aFileto be written to.- Returns:
falseif no appropriate writer is found.- Throws:
IllegalArgumentException- if any parameter isnull.IOException- if an error occurs during writing.
-
writeImage
public static boolean writeImage(IIOImage iioImage, String formatName, ImageOutputStream output) throws IOException Writes an image using the an arbitraryImageWriterthat supports the given format to anImageOutputStream. The image is written to theImageOutputStreamstarting at the current stream pointer, overwriting existing stream data from that point forward, if present.- Parameters:
iioImage- the image data to be written.formatName- aStringcontaing the informal name of the format.output- anImageOutputStreamto be written to.- Returns:
falseif no appropriate writer is found.- Throws:
IllegalArgumentException- if any parameter isnull.IOException- if an error occurs during writing.
-
getImageWriter
Gets an image writer suitable to be used for the given image type and image format.- Parameters:
imageType- the type of the image to be written laterimageFormatName- the image format name, e.g. "TIFF"- Returns:
- a suitable image writer, or
nullif no writer is found
-
getImageWriter
public static ImageWriter getImageWriter(ImageTypeSpecifier imageType, String imageFormatName, String metadataFormatName) Gets an image writer suitable to be used for the given image type, image format and metadata format.- Parameters:
imageType- the type of the image to be written laterimageFormatName- the image format name, e.g. "TIFF"metadataFormatName- the metadata format name, e.g. "com_sun_media_imageio_plugins_tiff_image_1.0", ornull- Returns:
- a suitable image writer, or
nullif no writer is found
-
getXML
-