Link

Write image files

You can easily replace ImageIO by adding the JDeli jar to your Java modulepath and then refactoring to use the JDeli methods.

For new code, JDeli works in a very similar way to ImageIO

For example, to write a jpeg image:

File myNewJPegFile = new File("ImageAsJPeg.jpg");
ImageIO.write(myBufferedImage, "jpg", myNewJPegFile);

becomes:

File myNewJPegFile = new File("ImageAsJPeg.jpg");
JDeli.write(myBufferedImage, "jpg", myNewJPegFile);

The supported output formats are:

  • BMP
  • GIF
  • HEIC/HEIF
  • JPEG/JPG
  • JPX/JP2
  • PDF
  • PNG
  • TIFF/TIF
  • WEBP

There are also some new write method versions of JDeli.write.

OutputFormat version of JDeli.write

write(BufferedImage image, OutputFormat format, File output)
write(BufferedImage image, OutputFormat format, OutputStream output)

OutputFormat provides an Enum to set the Image type and lists all supported formats.

EncoderOptions version of JDeli.write

write(BufferedImage image, EncoderOptions options, File output)
write(BufferedImage image, EncoderOptions options, OutputStream output)

Each image format has a version of EncoderOptions (ie JpegEncoderOptions) which provides for complete control over output and allows image processing. Each Image format has its own specific options to set and get Image-specific values (ie TiffEncoderOptions allows access to xmp metadata for Tiff files).

The full Javadoc can be found here.

Alternatively, if you do not want to change your code you can always use our ImageIO Plugin which does not require any refactoring.