DEV Community

IDRSolutions
IDRSolutions

Posted on

How to read AVIF files in Java (Tutorial)

In this article, I will explain how to read Avif files as Buffered Image in Java with some sample code.

ImageIO does not read Avif file type in Java, forcing you to use an external library or plugin.

If you are looking for a free solution, there is an AVIF library on GitHub (which includes Java wrappers). In this article we will be using our JDeli pure Java library to read Avif files.

How to read Avif files in Java with JDeli:

  1. Add JDeli to Your Project: Add JDeli to your class or module path. (download the trial jar ).
  2. Point to Your Avif Picture: Create a file handle, input Stream pointing to the raw Avif image. Alternatively, you can also use a byte[] containing the image data if your data is in that format.
  3. Read Avif pictures easily: Use JDeli to read the Avif image into a BufferedImage.

and the Java code to read AVIF…

File file = new File("/path/to/outputFile.AVIF"));
BufferedImage image = JDeli.read(file);
Enter fullscreen mode Exit fullscreen mode

Still struggling with how to read Avif files in Java?

You can contact us on Discord, Zoom or Email if you would like to find out more about how JDeli can help.

Top comments (0)