Link

Java JPEG Writer

JDeli includes a JPEG Writer to write JPEG files in Java. The JPEG Encoder is written in 100% Java with no dependencies.

Key information:

  • 100% Java solution. No dlls or dependencies on native code
  • Fast and easy to use
  • Supports quality settings

Quick start or to replace in existing code using ImageIO:

JDeli.write(myBufferedImage, "jpg", outputStreamOrFile);

or

byte[] outputData = JDeli.write(myBufferedImage, "jpg");

New method for quick and simple usage

JDeli.write(myBufferedImage, OutputFormat.JPEG, outputStreamOrFile)

OutputFormat allows setting of any supported Image Format

For complete control of output:

final JpegEncoderOptions options = new JpegEncoderOptions();

//set any options in options instance - examples below
options.setQuality(100);//0-100

//write out
JDeli.write(myBufferedImage, options, outputStreamOrFile);

JpegEncoderOptions allows setting of specific options.

Various image processing operations can be conducted on the image, detailed documentation can be found here.

Performance comparisons:

These figures were generated using jmh (as documented on our blog) with a standard set of images (also documented). They should be easy to replicate if you wish to validate, the code is on GitHub.

The higher the number, the better.

Mode: Throughput Count: 25 Units: ops/s

Benchmark Score Error
ImageIO 63.441 ± 1.793
JDeli 116.734 ± 5.112
JDeli_Quality_100 50.637 ± 2.592
JDeli_Quality_50 127.940 ± 4.790
Output files File size AVG
Reference 139.8KB
ImageIO 18.4KB
JDeli 18.2KB
JDeli Quality 100 18.3KB
JDeli Quality 50 12.8KB

Tested on 2020 13inch M1 MacBook Pro using JDK 18.0.1.1


Why JDeli?

  • Support image formats such as AVIF, HEIC and JPEG XL (AVIF soon) that are not supported in Java.
  • Process images up to 3x faster than ImageIO and alternative Java image libraries.
  • Prevent JVM crashes caused by native code in other image libraries such as ImageIO.
  • Handle JPEG, PNG, TIFF image file formats fully in Java.
  • Keep your Image files secure as JDeli makes no calls to any external system or third party library.

Start Your Free Trial