TL;DR:
Java’s ImageIO can write PNG files, but gives you almost no control over the output — no compression level, no colour depth options, no metadata handling. For basic use that is fine. If you need control over PNG output, you need an external library. JDeli is a pure Java option that works as a drop-in ImageIO plugin and provides a direct API with full encoder options.
Does Java support PNG natively?
Yes, but only at a basic level. ImageIO can write PNG files without any additional libraries:
File file = new File("/path/to/output.png");
ImageIO.write(bufferedImage, "PNG", file);
The problem is that ImageIO’s PNG writer exposes no encoder options. You cannot set compression level, choose colour depth, control interlacing, or embed metadata. For many use cases — especially where file size or image quality matter — this is a real limitation.
Which Java PNG library should you use?
| ImageIO (native) | Apache Imaging | JDeli | |
|---|---|---|---|
| Pure Java (no native binaries) | ✓ | ✓ | ✓ |
| Works as ImageIO plugin | ✓ | ✗ | ✓ |
| Direct API | ✗ | ✓ | ✓ |
| Compression level control | ✗ | Limited | ✓ |
| Colour depth options | ✗ | ✓ | ✓ |
| Supports other formats (AVIF, HEIC, WebP…) | ✗ | ✗ | ✓ |
| Cost | Free | Free | Commercial |
| Support | Community | Apache / community | Included |
Native ImageIO is sufficient for straightforward PNG output where file size and quality tuning are not a concern. Apache Imaging is a reasonable free option if you need more control. JDeli is the better choice for production use, or where you need consistent behaviour across formats and the ability to tune output precisely.
Option 1: Write PNG with native ImageIO
If you just need to produce a PNG file with no particular constraints, native ImageIO is the simplest route:
File file = new File("/path/to/output.png");
ImageIO.write(bufferedImage, "PNG", file);
Be aware that ImageIO will make its own decisions about compression and colour depth. For files destined for the web or storage-constrained environments, this can produce larger files than necessary.
Option 2: Add controlled PNG output to ImageIO (no code changes)
JDeli registers itself as an ImageIO plugin. Once it is on the classpath, your existing ImageIO.write() calls use JDeli 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.
// Your existing ImageIO code — no changes needed
File file = new File("/path/to/output.png");
ImageIO.write(bufferedImage, "PNG", file);
Option 3: Write PNG directly with the JDeli API
The JDeli API gives you explicit control over output and does not depend on ImageIO’s plugin registration order.
- Add JDeli to your class or module path. (download the trial jar)
- Create a
FileorOutputStreamfor the output. - Call
JDeli.write()with your image, format, and output target.
// String format
JDeli.write(bufferedImage, "PNG", new File("/path/to/output.png"));
// Type-safe enum (preferred)
JDeli.write(bufferedImage, OutputFormat.PNG, new File("/path/to/output.png"));
Controlling output with PngEncoderOptions
For production use, pass a PngEncoderOptions object to control compression and other output settings:
PngEncoderOptions options = new PngEncoderOptions();
JDeli.write(bufferedImage, options, new File("/path/to/output.png"));
See the JDeli PNG documentation for the full list of encoder options.
Frequently asked questions
Does Java support PNG natively?
Yes, but with limited control. ImageIO can write PNG files without any additional library, but exposes no encoder options. You cannot control compression level, colour depth, or interlacing without an external library such as JDeli.
Why is my PNG file larger than expected?
ImageIO’s PNG writer makes its own compression decisions and offers no way to tune them. Using JDeli with PngEncoderOptions gives you direct control over compression level, which can significantly reduce file size without quality loss — PNG compression is lossless.
What is JDeli?
JDeli is a pure Java image library from IDR Solutions. It has no native binaries, works as both an ImageIO plugin and a standalone API, and supports PNG alongside other formats including AVIF, HEIC, TIFF, and WebP.
Can I read PNG files in Java with JDeli?
Yes. See our companion article: how to read PNG files in Java.
Is JDeli pure Java?
Yes. JDeli has no native binaries and makes no calls to platform-specific libraries, making it straightforward to deploy on any Java-supported platform including containerised and server environments.
Other useful PNG resources
- How to read PNG files in Java
- How to convert PNG to JPG in bulk
- What is the PNG format?
- JDeli PNG support documentation
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?
// Read an image
BufferedImage bufferedImage = JDeli.read(avifImageFile);
// Write an image
JDeli.write(bufferedImage, "avif", outputStreamOrFile);// 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.
How does JDeli compare?
We work hard to make sure JDeli performance is better than or similar to other java image libraries. Check out our benchmarks to see just how well JDeli performs.
