How to Convert HEIC to JPG in Java
Convert between over 100 file formats, including key formats such as Photoshop (PSD), PNG, JPG, GIF, NEF, and BMP.
Join the DZone community and get the full member experience.Join For Free
Apple Products are known for having extremely high-quality cameras with the ability to capture dynamic and high-definition images using your easily accessible mobile device. This means you do not need to carry around traditional, heavy cameras that must be handled with care due to their fragility. Instead, your phone can be used to seize the moment whenever inspiration hits. Furthermore, Apple devices can take Live Photos, which are somewhat like GIFs in that they capture a short period of movement while the picture is taken. Unlike GIFs, however, Live Photos also record an audio clip to go with the image.
These images, though they can easily meet the needs of any project due to their clarity and definition, are not saved in an easily transferable format. The HEIC file format is the default for all iPhone and Apple images, which is how they can retain their quality, but this format is not compatible with many different Operating Systems. While Macs now have the ability to read HEIC, Windows 10 does not have any built-in support and needs a third-party viewer to access them.
The following APIs will allow you to instantly convert HEIC image files to JPG, GIF, PNG, and more for improved compatibility across devices. However, both APIs also support over 100 image file formats, so you could convert any image you want into any other format by simply specifying the formats in the function input. The first API shown below can convert a singular image between file formats, while the second can process and convert multi-page file formats.
For both APIs, you will first need to install the SDK library. To install with Maven, you will need to add a Jitpack reference to the repository in pom.xml:
Then, you can add a reference to the dependency:
To install with Gradle, add the reference in your root build.gradle at the end of repositories:
Then, add the dependency in build.gradle:
The input for both APIs will be the original image file format, the desired conversion format, and the valid input file.
After you have installed the SDK, you will need to add the imports to the top of the function, and then call it:
This will return a downloadable image file that can then be used wherever you need it. To ensure that this API works properly, you need to ensure certain requirements are met:
- Your input file is valid and not encrypted or password protected
- You have input your API Key. This can be retrieved at no cost on the Cloudmersive website, providing 800 monthly calls across our API library.
If either of these parameters are not met, you may be unable to use the functions, or you may receive an error code on running the API.
As stated before, this second API will be useful for those who need to convert multi-page image files such as PDFs and TIFFs. The SDK library, parameters, and supported file formats will all be the same as the previous function.
Once you have installed the SDK, add the imports to the file and call the function:
With these functions, you can convert any image or image array between file formats to best meet your compatibility and project needs.
If you have any questions about using these APIs or inquiries concerning other API solutions, you can visit the Cloudmersive website where our team is happy to help with anything you might need.
Opinions expressed by DZone contributors are their own.