In this article, I will show you how to read JPEG XL images in Java. JPEG XL is a relatively new format so it is not currently supported by Apache Commons Imaging.
How to read JPEG XL images in Java with Jxlatte
Jxlatte is a ‘work-in-progess’ JPEG XL Decoder which can be used to convert to better supported Image formats using this code
java -jar jxlatte.jar samples/art.jxl output.png
How to read a JPEG XL image with Java ImageIO
Java ImageIO is able to read these images with an additional plugin. There are some Java wrappers for the JPEG-XL library here. These allow you to read the image to a BufferedImage but do not offer a totally native solution.
BufferedImage img = ImageIO.read(Paths.get("/foo/bar.jxl").toFile())
How to read a JPEG XL image in Java with JDeli
JDeli supports reading JPEG XL image files out of the box. You can convert JPEG XL files into other formats directly in JDeli. You can also directly read any JPEG XL image into a Java BufferedImage with this code.
- Add JDeli to your class or module path (download the trial jar).
- Create a File handle, InputStream pointing to the raw JPEG XL image. You can also use a byte[] containing the image data.
- Read the JPEG XL image into a BufferedImage
and the Java code to read JPEG XL…
File file = new File("/path/to/image.jxl");
BufferedImage img = JDeli.read(file);
Are you a Java Developer working with Image files?
// Read an image
BufferedImage bufferedImage = JDeli.read(dicomImageFile);
// Read an image
BufferedImage bufferedImage = JDeli.read(heicImageFile);
// Write an image
JDeli.write(bufferedImage, "heic", outputStreamOrFile);
// Read an image
BufferedImage bufferedImage = JDeli.read(jpegImageFile);
// Write an image
JDeli.write(bufferedImage, "jpeg", outputStreamOrFile);
// Read an image
BufferedImage bufferedImage = JDeli.read(jpeg2000ImageFile);
// Write an image
JDeli.write(bufferedImage, "jpx", outputStreamOrFile);
// Write an image
JDeli.write(bufferedImage, "pdf", outputStreamOrFile);
// Read an image
BufferedImage bufferedImage = JDeli.read(pngImageFile);
// Write an image
JDeli.write(bufferedImage, "png", outputStreamOrFile);
// Read an image
BufferedImage bufferedImage = JDeli.read(tiffImageFile);
// Write an image
JDeli.write(bufferedImage, "tiff", outputStreamOrFile);
// Read an image
BufferedImage bufferedImage = JDeli.read(webpImageFile);
// Write an image
JDeli.write(bufferedImage, "webp", outputStreamOrFile);
What is JDeli?
JDeli is a commercial Java Image library that is used to read, write, convert, manipulate and process many different image formats.
Why use JDeli?
To handle many well known formats such as JPEG, PNG, TIFF as well as newer formats like AVIF, HEIC and JPEG XL in java with no calls to any external system or third party library.
What licenses are available?
We have 3 licenses available:
Server for on premises and cloud servers, Distribution for use in a named end user applications, and Custom for more demanding requirements.
What's our Story?
We are a small company who have been developing innovative Java, PDF and HTML5 solutions for over 25 years.