Link
Skip to main content

Java GIF Writer

Java’s built-in ImageIO has limited support for writing GIF files and provides little control over encoding quality and format-specific options. JDeli is a 100% Java GIF writer that gives you full encoding control with no dependencies.

Getting started

Add JDeli to your project via Maven or Gradle, or see using JDeli with Java modules.

Key features:

  • 100% Java solution. No dlls or dependencies on native code
  • LZW compressed

Quick start or to replace in existing code using ImageIO:

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

or

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

Simple usage

JDeli.write(myBufferedImage, OutputFormat.GIF, outputStreamOrFile);

OutputFormat allows setting of any supported Image Format

For complete control of output:

final GifEncoderOptions options = new GifEncoderOptions();


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

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

Benchmark Score Error
Apache 1.705 ± 0.251
ImageIO 4.713 ± 0.025
JDeli 0.538 ± 0.003

Number of files: 166

Benchmark Size unreadable output AVG SSIM score AVG Similarity
Apache 590.01KB 0 0.8785090614816008 Similar (noticeable but minor differences)
ImageIO 404.11KB 4 0.18769307741202973 Very different
JDeli 721.95KB 0 0.8284792072170122 Moderately similar (visible differences)

Frequently asked questions

Does JDeli produce better GIF output than Java ImageIO?

Yes. While ImageIO can write GIF, JDeli gives you full control over encoding options such as compression and quality, and produces more consistent output across platforms.

Does writing GIF in Java require native libraries?

No. JDeli is a 100% Java library with no dependencies. It runs on any platform where the JVM runs with no additional installation.

What output types does JDeli support for writing GIF?

JDeli can write GIF to a File, OutputStream, or return the encoded data as a byte array.


Why JDeli?

  • Support image formats such as AVIF, HEIC and JPEG XL 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.

Learn more about JDeli

Start Your Free Trial