Pure Java does not support HEIC. If you use ImageIO to read/ write HEIC image, it won’t work without another plugin. Therefore, this blog tells you how to add HEIC support to a Java app.
What is HEIC?
HEIC stands for “High-Efficiency Image Container” and it is a specific implementation for still images inside HEIF. It was developed by MPEG and adopted by Apple but is an Open Standard. You can learn more about it in this blog.
What libraries/ plugins to consider for HEIC support in Java?
It depends on your use cases. If you are working on your personal projects and do not plan to pay for any commercial solutions, you can try to find free open source ones. However, if you are a professional Java developer working on an enterprise-level project that requires high security and low support effort, JDeli would be a great choice for you.
What is JDeli and why should you use it?
JDeli is a Java image library developed by IDRSolutions. It is designed for Java developers and is used by global large companies like Abacus, Mercedes-Benz Bank, Clearsense, etc.
JDeli is well-known for its advantage in premium support, easy integration, high security, outstanding performance, and simple pricing plan. You can read this blog to learn more about why JDeli is a great enterprise-level Java image library.
How to add HEIC support in Java with JDeli?
It’s actually very simple and can be done without rewriting large pieces of your existing code!
For example, below codes with ImageIO wouldn’t work:
// Read HEIC image into Java with ImageIO
BufferedImage bufferedImage = ImageIO.read(new File("heicImageFile.heic"));
// Write out BufferedImage as HEIC image file with ImageIO
ImageIO.write(bufferedImage, "heic", new File("heic"));
But if you download the JDeli trial jar with our ImageIO plugin, follow the support document to install it, then ImageIO will use JDeli and the above code will work. Alternatively, you can and replace ImageIO with JDeli:
// Read HEIC image into Java with JDeli
BufferedImage bufferedImage = JDeli.read(new File("heicImageFile.heic"));
// Write out BufferedImage as HEIC image file with JDeli
JDeli.write(bufferedImage, "heic", new File("heic"));
Now this code works like magic!
Conclusion
Adding HEIC support in Java can be done very simply with JDeli. All you need to do is replacing ImageIO with JDeli in your codes. Click here to try it out!
Top comments (0)