If you’re dealing with a large collection of images in HEIC format, converting HEIC files to JPG in bulk can be a lifesaver. HEIC (High Efficiency Image Coding) is a format used by Apple and it is a proprietary image format used across all their devices.
However, it’s not always compatible with other technologies. This becomes a problem with use cases such as when Java developers want to integrate HEIC images into their existing applications.
In this article, I’ll guide you through the process of using Java to convert HEIC files to JPG format with JDeli, ensuring your images are accessible.
Convert HEIC to JPG in bulk using Java
- Download the JDeli trial jar.
- Process image if needed (scale, sharpen, lighten, watermark, etc)
- Write out BufferedImage as JPG image file
BufferedImage bufferedImage = JDeli.read(new File("heicImageFile.heic"));
// Read HEIC image into Java
bufferedImage = operations.apply(BufferedImage bufferedImage);
// Process image (Optional)
JDeli.write(bufferedImage, "jpg", new File("jpgImageFile.jpg"));
// Write out BufferedImage as JPEG image file
Export HEIC to JPG in one line of code
With the JDeli.convert()
method you can save HEIC as JPG in just one line of code.
Using File
JDeli.convert(File inFile, File outFile);
Using InputStream and OutputStream
JDeli.convert(InputStream inputStream, OutputStream outputStream, "jpg");
Using byte[]
byte[] outputData = JDeli.convert(byte[] inputData, "jpg");
Configure Output Settings
This option allows you to specify an EncoderOptions object to configure output settings such as image compression.
JDeli.convert(File inFile, EncoderOptions outputOptions, File outfile);
How to bulk convert HEIC to JPG from the command line
You can convert bulk heic to jpg from command line or bash, bat, and powershell scripts. This method can also be used to invoke JDeli from any programming language that allows you to create a child process.
java -jar jdeli.jar –convert jpg "inputFileOrDir" "outputDir"
In this tutorial you learned how to convert HEIC to JPG in bulk, you can also have a look at our tutorials for more format conversions.