Mark Stephens Mark founded the company and has worked with Java and PDF since 1997. The original creator of the core code, he is also a NetBeans enthusiast who enjoys speaking at conferences and reading. He holds an Athletics Blue and an MA in Mediaeval History from St. Andrews University.

How to write HEIC image files in Java (Tutorial)

3 min read

heic file icon

how to write HEIC image (HEIC icon)

TL;DR:

Java’s ImageIO has no HEIC support. To write HEIC files in Java you need an external library. JDeli is the only pure Java implementation — it works as a drop-in ImageIO plugin with no code changes required, and also provides a direct API. A free alternative using native binaries is available via Nokia’s HEIF library on GitHub.

Does Java support HEIC natively?

No. ImageIO has no HEIC codec. Both reads and writes fail silently or return null without an external library:

// Both of these fail with vanilla ImageIO
// Read
BufferedImage image = ImageIO.read(new File("input.heic")); // returns null
// Write
ImageIO.write(bufferedImage, "heic", new File("output.heic")); // returns false

HEIC is the default image format for Apple devices and is increasingly common in production environments. You need an external library to handle it in Java.

Which Java HEIC library should you use?

JDeliNokia HEIF (Java wrappers)
Pure Java (no native binaries)✗ (wraps native libs)
Works as ImageIO plugin
Direct API
Read and write HEIC
Encoder options (quality, compression)Limited
Supports other formats (AVIF, WebP, TIFF…)
CostCommercialFree
SupportIncludedGitHub issues
Actively developedLimited

The Nokia library is a reasonable free option if native binaries are acceptable in your environment. JDeli is the better choice for server deployments, containerised environments, or anywhere distributing platform-specific binaries is impractical or a security concern.

Option 1: Add HEIC support to ImageIO (no code changes)

JDeli registers itself as an ImageIO plugin. Once it is on the classpath, your existing ImageIO.read() and ImageIO.write() calls handle HEIC automatically with no code changes required.

Maven

<dependency>
    <groupId>com.idrsolutions</groupId>
    <artifactId>jdeli</artifactId>
    <version>[JDELI_VERSION]</version>
</dependency>

Gradle

implementation 'com.idrsolutions:jdeli:[JDELI_VERSION]'

Alternatively, download the trial jar and add it to your classpath manually. See the ImageIO configuration guide for setup details.

Once JDeli is on the classpath, your existing ImageIO code works unchanged:

// Read — works once JDeli is on the classpath
BufferedImage bufferedImage = ImageIO.read(new File("input.heic"));
// Write — same
ImageIO.write(bufferedImage, "heic", new File("output.heic"));

Option 2: Write HEIC directly with the JDeli API

The JDeli API gives you more control and does not depend on ImageIO’s plugin registration order.

  1. Add JDeli to your class or module path. (download the trial jar)
  2. Create a File or OutputStream for the output.
  3. Call JDeli.write() with your image, format, and output target.
// String format
JDeli.write(bufferedImage, "heic", new File("/path/to/output.heic"));
// Type-safe enum (preferred)
JDeli.write(bufferedImage, OutputFormat.HEIC, new File("/path/to/output.heic"));

Controlling output with HeicEncoderOptions

For production use, pass a HeicEncoderOptions object to control quality and other output settings:

HeicEncoderOptions options = new HeicEncoderOptions();
JDeli.write(bufferedImage, options, new File("/path/to/output.heic"));

See the JDeli HEIC documentation for the full list of encoder options.

Frequently asked questions

What is the HEIC format?

HEIC (High Efficiency Image Container) is Apple’s default image format, used on iPhone and iPad since iOS 11. It is based on the HEVC codec and typically produces files around half the size of equivalent JPEG images at the same visual quality. It supports transparency, HDR, and sequences of images (used for Live Photos).

Why does Java not support HEIC?

Java’s ImageIO is extensible but ships with a limited set of built-in codecs. HEIC is a relatively recent format with patent and licensing considerations, so it was not added to the standard library. An ImageIO plugin such as JDeli adds the missing support.

Can I read HEIC files in Java with JDeli?

Yes. See our companion article: how to read HEIC files in Java.

Is JDeli pure Java?

Yes. JDeli has no native binaries and makes no calls to platform-specific libraries. This makes it straightforward to deploy on any Java-supported platform, including containerised and server environments.

Can I convert HEIC to JPG in Java?

Yes. See our tutorial: how to convert HEIC to JPG in bulk.

Other useful HEIC resources

As experienced Java developers, we help you work with images in Java and bring over a decade of hands-on experience with many image file formats.



Are you a Java Developer working with Image files?

Mark Stephens Mark founded the company and has worked with Java and PDF since 1997. The original creator of the core code, he is also a NetBeans enthusiast who enjoys speaking at conferences and reading. He holds an Athletics Blue and an MA in Mediaeval History from St. Andrews University.