×

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

  1. createImageInputStream(Object input)
    It returns an ImageInputStream with the specified Object as its source of input.
  2. createImageOutputStream(Object output)
    It provides a response in the form of an ImageOutputStream that outputs to the specified Object.
  3. getCacheDirectory()
    It returns either null if no explicit setting has been made or the actualvalue set by setCacheDirectory.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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.
  9. 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.
  10. 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.
  11. 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.
  12. 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.
  13. 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.
  14. 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.
  15. 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.
  16. 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.
  17. getReaderMIMETypes()
    It returns a list of all the MIME types that are currently recognised by the registered readers, organized as an array of Strings.
  18. getUseCache()
    Returns true if no particular setting has been made, or the set point set by setUseCache.
  19. getWriterFileSuffixes()
    Returns a list of all the file suffixes connected to the formats that the present group of registered writers is familiar with.
  20. 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.
  21. getWriterMIMETypes()
    It returns an array containing Strings listing every MIME type that the current group of registered writers is capable of understanding.
  22. 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.
  23. 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.
  24. 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.
  25. 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.
  26. 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.
  27. setCacheDirectory(File cacheDirectory) 
    stablish the location of the cache files' creation directory.
  28. setUseCache(booleanuseCache) 
    Enable the usage of a disk-based cache directory when constructing image input and output streams by setting a flag indicating this.
  29. write(RenderedImageim, String formatName, File output) 
    It uses any ImageWriter which supports the specified format to write an image to a File.
  30. ImageOutputStream.
    write(RenderedImageim, String formatName, OutputStream output) uses any ImageWriter which supports the specified format to write an image to an OutputStream.

Related Topics

Difference Between Data Hiding and Abstraction in Java

Abstraction: Data Abstraction and Data Hiding ideas are utilised to show the expected data to the end client and conceal the superfluous subtleties, however, for specific purposes like decreasing the framework's...

10 minutes read.

Compile-time Error in Java

In java, the execution of a program is stopped due to the occurrence of some problem known as an error. Errors are illegal operations that are carried out by the...

4 minutes read.

Grepcode Java util date

What is java.util.Date Class? The date and time in Java are provided through the java.util.Date class. If you imported java.util, it could be helpful. Use the Java.util.Date class to implement this class...

4 minutes read.

Deadlock Prevention and avoidance in Java

This tutorial will discuss deadlock prevention and Avoidance in Java programming language. Introduction Multithreading in Java includes deadlock. We can multitask by running several threads concurrently in the multithreading environment. Deadlock occurs...

4 minutes read.

Swapping Program in Java

Swapping Program in Java The swapping program in Java is used to interchange the values of the two variables. For example, if X = 12 and Y = 24, then the...

4 minutes read.

House Numbers in Java

In this section, we will discuss about house number in Java. It is a sum of cubes, each of which has a dimension of h + 1. There is a...

3 minutes read.

Date time API in java

Introduction: In this text, we can talk approximately Data time API in java. The java.time, java.util, java.sql, and java.text packages contain classes that represent dates and times. The following classes are...

4 minutes read.

How to set timer in Java

In this article, you will be very well equipped with the knowledge to set timer in java. The timer in java can be set by using timer class provided by...

3 minutes read.

Java Primitive Data Types

Primitive data types are the simplest data types in a programming language. They’re predefined in the language. The names of the primitive types are quite descriptive of the values that...

2 minutes read.

Java Framework List

The framework is the programs which are written in Java. Frameworks in Java are used to create web applications. The code which can reuse can act as a reference for...

6 minutes read.

String isnullorempty in Java

What do you mean by String? Strings are a collection of characters that are commonly used in Java programming. Strings are regarded as objects in the Java programming language. “String” is a...

4 minutes read.

How to compare characters in Java

In this tutorial, we will learn about how to compare characters in Java. To compare characters in Java, we will learn about what is a character in Java Char The character is...

4 minutes read.

Java Math.multiplyExact() method in Java

Java has an inbuilt math function called Math.multiplyExact() that returns the sum of the parameters. If the result exceeds an integer, an exception is thrown. There is no need to...

2 minutes read.

Types of Events in Java

One of Java's key ideas is the principle of an event. Events in Java are activities that result in a change in the state or behavior of an object. The...

4 minutes read.

Java Worker Class

What is a Worker? A service which executes Work - flow and Activities is referred to as a Worker. On user-controlled hosts, workers are defined and put into action. The Worker...

3 minutes read.

File Operation in Java

In Java, a file is an Abstract data type. These are used to store the data which is related. Files are named storage locations. With a file we can perform...

7 minutes read.

Model Class in Java

In this section, we will be acknowledged about the model class in Java, its purpose and its uses. Also, we will learn how is this created and leveraged in java. Model...

4 minutes read.

The Diamond Operator in Java 7

The Diamond operator is a comparatively recent Java operator originally developed in JDK 7 to enhance type identification and eliminate boilerplate Java code. The Diamond operator is characterized by a...

2 minutes read.

Java While Loop

A while loop is used to repeatedly execute a set of statements as long as its condition evaluates to true. This loop checks the condition before it starts the execution...

1 minute read.

Java Solid Principles

Java implements the object-oriented SOLID principles for the design of software architecture. Solid Principles Java implements the object-oriented SOLID principles for the design of software architecture.   Five guiding principles transformed...

4 minutes read.