×

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

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.

Comparetoignorecase in Java

In Java, the function compareToIgnoreCase ( ) is part of the String class, which is part of the java.lang package. It is used to compare any two strings while disregarding...

4 minutes read.

Why String in Immutable in Java?

Why String in Immutable in Java Immutable means unchangeable or unmodifiable.  Strings in Java are immutable, it means once a string is created, it cannot be modified or changed. Any change...

2 minutes read.

Read JSON file in Java

 To know about reading a JSON file in Java first we must know about the JSON file. JSON: JSON is “JavaScript Object Notation”. The JSON is the simple format for storing and...

3 minutes read.

Session Tracking in Java

When a series of requests from the same User (i.e., requests coming from the same browser) occurs over an extended period of time, servlets employ a mechanism known as session...

3 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 Interface Keyword

An interface is also known as the blueprint in Java. It has constants of static values and methods of abstraction. The interface is a mechanism used by Java to declare...

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

Bully Algorithm code in Java

Election algorithms include the bully algorithm, mainly used to select a coordinate. To find a coordinator in a distributed system that can carry out the tasks required by other processes,...

4 minutes read.

Static() Function in Java

The static keyword in Java is suitable for variables, constants, and functions. The static keyword is mainly used to control storage so that it may be appropriately used. We shall...

3 minutes read.

InputMismatchException in Java

What is InputMismatchException? One of the most frequent errors in Java is the InputMismatchException. Because the InputMismatchException is a subtype of the java.lang, it is an unchecked exception. RuntimeException.Because it is...

4 minutes read.

Pyramid Program in Java

Pyramid Program in Java In the previous section, we have discussed about the number pattern programs in Java. The logic for the number pattern and pyramid pattern is the same except...

2 minutes read.

How to declare string array in Java

Introduction Array is a data structure with a fixed size, which allows us to store elements of similar type. Data of primitive types like int, char, float, string, etc. can be...

2 minutes read.

Accessors and Mutator in Java

Introduction Accessors and mutators are used in Java to get and set the value of private fields, respectively. Accessors and mutators are both referred to as getters and setters, respectively. The...

6 minutes read.

Java Math abs() Method

The abs() method of Math class returns the absolute value of the argument where the argument can be int, double, float, long. Syntax public static int abs(int a) public static float abs(float a) public...

2 minutes read.

Java vs JavaScript

Java Vs JavaScript Java and JavaScript, both play an important role in the field of Computer Technology. Most people think JavaScript is a part of Java. But it is not entirely...

4 minutes read.

Difference between String, StringBuffer and StringBuilder in java

What is a string in Java? 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.

Java Int Keyword

Among the primitive data types is the Java int keyword. To declare variables, use this. It can also be used with methods that return values of the integer type. It...

3 minutes read.

How to encrypt password in Java

Every software program needs a username and password to identify a legitimate user. A username can be any number of things, including an email address or a string of characters....

6 minutes read.

Stone Game in Java

In this tutorial, we will learn to design a stone game in Java. First of all, we will understand what is this game all about. We will grasp it through...

9 minutes read.