×

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

Print Matrix Diagonally in Java

The aim is to print the elements of a matrix of size n*n in some kind of a diagonal pattern. Input : mat[3][3] = {{1, 2, 3},                      {4, 5, 6},                      {7,...

3 minutes read.

Singleton Design Pattern in Java

In the singleton pattern, a class that only has one instance and offers a universal point of access is taken into consideration. It can also be defined in another way, a...

4 minutes read.

Activity selection problem in Java

The activity selection problem is a multiple objective problem hat requires choosing non-conflicting tasks to complete within a specific amount of time from a list of tasks identified by a...

5 minutes read.

Converting Long to Date in Java

What Long and Date are in Java and how are they implemented in the Java programming language are the topics of this article. Additionally, we'll go into great detail on...

4 minutes read.

Java Developer

Who is a Java Developer? A Java developer is a skilled programmer who works on commercial applications, software, and webpages.  Java developers can work in two different areas: Operating system development:...

3 minutes read.

Features of Java

The objective of the Java programming language is to provide portability, security, and simplicity. In spite of this, Java has a number of features that makes it a popular language...

5 minutes read.

Set Up the Environment in Java

The Java is regarded as the pure object-oriented programming language. The Java applications are first compiled into the byte-code and then run by using the JVM. The Java is the...

4 minutes read.

List all files in a Directory in Java

The list of all files in the directory can be done using Java. You should be aware that a directory may include a subfolder and that subdirectory may also contain some...

3 minutes read.

3N+1 problem program in Java

The 3N+1 problem is a hypothesis in the field of abstract mathematics (not yet proven). Collectively known as the Collatz problem. This tutorial will describe about the 3N+1 problem and...

3 minutes read.

Java Integer getInteger() method

The getInteger() method of Integer class determines the integer value of the system property with the given name. Syntax` public static Integer getInteger(String nm) Parameters The parameter ‘nm’ represents the property name. Throws The getInteger ()...

1 minute read.

Java LDAP Authentication

WHAT IS LDAP? Clients can communicate with directory services by sending requests and receiving responses using the Lightweight Directory Access Protocol (LDAP). The term "LDAP server" refers to a directory service...

7 minutes read.

Java Custom Exception

Java Custom Exception Java language facilitates us to create our own exceptions. The class intended to throw the Custom Exception has to be derived from the Java Exceptionor RuntimeExceptionclass. The Java...

4 minutes read.

Non-primitive data types in Java

The kind of data stored in the variable is determined by its type. The type describes the data category (different sizes and values). These are not already built into the devices....

4 minutes read.

How to Iterate a HashMap in Java?

Hash-map is a class of Java collections framework which has the functionality to implement the Map interface of Java. It stores the data in key-value pairs and can be accessed...

5 minutes read.

Java program to find frequency of characters in a string

In this article, you will understand the how to find the frequency of characters in strings by using Java programming language. Along with this, you will understand the hashing concept...

3 minutes read.

How to compare two dates in different format in Java?

We need to compare two dates frequently when coding. Real-world examples include sorting a list of persons by age or keeping track of students' attendance. To compare two dates, we...

7 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.

Shopping Bill in Java

Java Shopping Bill Here in this program, we are about to create a JAVA class called Products which will have some properties or attributes like prod_name (Product Name ), qty (quantity),...

4 minutes read.

Java Finally Keyword

The final block in Java is used to run essential code, such as connection closure, among other things. Whether an exception is resolved or not, the Java finally block has...

3 minutes read.

Differences between Byte Code and Machine Code

This tutorial will discuss the differences between Byte Code and Machine Code. Before that, let's try to know what byte and machine code is. Introduction Every computer has a set of instructions...

4 minutes read.