Java Imageio
The javax.imageio package contains the final class known as Java ImageIO. For easy image reading, writing, and simple encoding and decoding, the class offers a convenient way. The class offers a variety of useful methods for processing images. We can work with common image extensions like.jpg,.bmp,.gif,.png, etc. by using the class. We will also go through how to both read and write images using the Java ImageIO class in this section.
ImageIO Class Methods in Java
- createImageInputStream(Object input)
It returns an ImageInputStream with the specified Object as its source of input. - createImageOutputStream(Object output)
It provides a response in the form of an ImageOutputStream that outputs to the specified Object. - getCacheDirectory()
It returns either null if no explicit setting has been made or the actualvalue set by setCacheDirectory. - getImageReader(ImageWriter writer) (ImageWriter writer)
Returns a related ImageReader for the specified ImageWriter, if one exists, or null if the supplied ImageWriter also isn't registered or when the plug-in for all of this ImageWriter does not define a corresponding ImageReader. - getImageReaders(Object input)
Returns an Iterator that contains every ImageReader that is currently listed as being capable of decoding the specified Object, which is often an ImageInputStream. - getImageReadersByFormatName(String formatName)
It returns an Iterator with a list of all presently active ImageReaders that have registered and claim to be able to decode the specified format. - getImageReadersByMIMEType(String MIMEType)
Returns an Iterator that contains a list of all ImageReaders that are currently listed as being able to interpret files with the specified MIME type. - getImageReadersBySuffix(String fileSuffix)
It returns an Iterator with a list of all ImageReaders that are currently listed as being capable of decoding files with the specified suffix. - getImageTranscoders(ImageReader reader, ImageWriter writer)
It provides an Iterator containing every ImageTranscoder that is currently registered and makes a claim to be able to convert between both the metadata of the specified ImageReader and ImageWriter. - getImageWriter(ImageReader reader)
It returns a corresponding ImageWriter for the supplied ImageReader, if one exists, or null if the supplied ImageReader is really not registered or the plug-in for such a ImageReader does not define a corresponding ImageWriter. - getImageWriters(ImageTypeSpecifier type, String formatName)
Returns an Iterator containing every registered ImageWriter that states they can encode images of the specified layout (specified using an ImageTypeSpecifier) in the specified format. - getImageWritersByFormatName(String formatName)
It returns an Iterator that is comprised of all ImageWriters that are currently listed as being able to encode the specified format. - getImageWritersByMIMEType(String MIMEType)
It returns an Iterator that contains a list of all ImageWriters that are currently listed as being able to memorize files with the specified MIME type. - getImageWritersBySuffix(String fileSuffix)
It returns an Iterator with a list of all ImageWriters that are currently listed as being capable of encoding files with the specified suffix. - getReaderFileSuffixes()
Gives back a list of all the file suffixes connected to the formats that the current group of registered readers is capable of understanding, represented as an array of Strings. - getReaderFormatNames()
It provides a list of all the unstructured format names that are familiar to the current group of registered readers as an array of Strings. - getReaderMIMETypes()
It returns a list of all the MIME types that are currently recognised by the registered readers, organized as an array of Strings. - getUseCache()
Returns true if no particular setting has been made, or the set point set by setUseCache. - getWriterFileSuffixes()
Returns a list of all the file suffixes connected to the formats that the present group of registered writers is familiar with. - getWriterFormatNames()
It returns a list of Strings containing all of the unstructured format names that the current group of authors who are registered can understand. - getWriterMIMETypes()
It returns an array containing Strings listing every MIME type that the current group of registered writers is capable of understanding. - read(File input) (File input)
It returns a BufferedImage after decoding a provided File using an ImageReader that is automatically selected from the list of registered ImageReaders. - read(ImageInputStream stream)
It returns a BufferedImage after decoding a provided ImageInputStream using an ImageReader that is automatically selected from the list of registered ImageReaders. - read(InputStream input)
It returns a BufferedImage after decoding a provided InputStream using an ImageReader that is automatically selected from the list of registered ImageReaders. - read(URL input)
It returns a BufferedImage after decoding a specified URL using an ImageReader that is automatically selected from the list of registered ImageReaders. - scanForPlugins()
Checks the approval procedures path for plug-ins, loads their network operator classes, as well as installs a service provider version for each of them found using the IIORegistry. - setCacheDirectory(File cacheDirectory)
stablish the location of the cache files' creation directory. - setUseCache(booleanuseCache)
Enable the usage of a disk-based cache directory when constructing image input and output streams by setting a flag indicating this. - write(RenderedImageim, String formatName, File output)
It uses any ImageWriter which supports the specified format to write an image to a File. - ImageOutputStream.
write(RenderedImageim, String formatName, OutputStream output) uses any ImageWriter which supports the specified format to write an image to an OutputStream.