Openize.HEIC for Java
Simplify Process of Reading and Converting HEIC Images Using Java API
Effortlessly edit images with Openize.HEIC, a lightweight open-source Java API, streamlining HEIC files convertion and automation
Openize.HEIC for Java revolutionizes your HEIC image processing experience. In this comprehensive guide, we delve into the functionalities and benefits of leveraging Openize.HEIC, a lightweight open-source Java API, to effortlessly handle HEIC files with ease.
HEIC, short for High Efficiency Image File Format with HEVC (High Efficiency Video Coding) encoded images, is a modern image format developed to replace JPEG as the default image format on iOS devices. While HEIC offers superior image quality and compression, its compatibility across platforms remains a challenge. Many applications and platforms lack native support for HEIC, making it difficult to view or edit these files without conversion.
Openize.HEIC emerges as a powerful solution for seamlessly converting HEIC files to various formats, including JPG, PNG, PDF and more. This lightweight open-source Java API simplifies HEIC image operations, offering developers and users a user-friendly interface to handle HEIC files effortlessly.
Openize.HEIC is available under Openize License.
Key Features and Benefits- Effortless Conversion: Convert HEIC files to popular formats such as JPG and PNG with a few lines of code.
- HEVC Decoder Integration: Utilize the built-in HEVC decoder to decode HEIC files, ensuring accurate and reliable conversion.
- Extensive Format Support: Convert HEIC files to a wide range of formats, including PDF and WEBP, enabling versatile usage across different platforms and applications.
- Open Source and Free: Enjoy the benefits of an open-source solution with no licensing fees, making it accessible to developers and users of all levels.
- Seamless Integration with Java Applications: Integrate Openize.HEIC effortlessly into your Java applications, enabling seamless HEIC file handling within your existing workflows.
- Effortless Conversion: Convert HEIC files to popular formats such as JPG and PNG with a few lines of code.
- HEVC Decoder Integration: Utilize the built-in HEVC decoder to decode HEIC files, ensuring accurate and reliable conversion.
- Extensive Format Support: Convert HEIC files to a wide range of formats, including PDF and WEBP, enabling versatile usage across different platforms and applications.
- Open Source and Free: Enjoy the benefits of an open-source solution with no licensing fees, making it accessible to developers and users of all levels.
- Seamless Integration with Java Applications: Integrate Openize.HEIC effortlessly into your Java applications, enabling seamless HEIC file handling within your existing workflows.
How to Get Started with Openize.HEIC for Java
Getting started with Openize.HEIC is quick and easy. Simply follow these steps:
- Install Openize.HEIC: Install the Openize.HEIC package via Maven/Gradle.
- Integrate with Your Project: Reference the Openize.HEIC library in your Java project.
- Start Converting: Utilize the simple API provided by Openize.HEIC to convert HEIC files to your desired format.
The recommended way to install Openize.HEIC for Java is using Maven/Gradle. Please use the following command for a smooth installation.
Install Openize.HEIC for Java via Maven
First you need to specify Aspose Maven Repository configuration / location in your Maven pom.xml as follows:
<repositories>
<repository>
<id>AsposeJavaRepo</id>
<name>Aspose Java Repository</name>
<url>https://releases.aspose.com/java/repo/</url>
</repository>
</repositories>
Then define dependency in your pom.xml as follows:
<dependencies>
<dependency>
<groupId>openize</groupId>
<artifactId>openize-heic</artifactId>
<version>25.4</version>
</dependency>
<dependency>
<groupId>openize</groupId>
<artifactId>openize-heic</artifactId>
<version>25.4</version>
<classifier>javadoc</classifier>
</dependency>
</dependencies>
You can also download it directly from GitHub.Read HEIC File into Array in Java
This code snippet efficiently loads a HEIC image file, extracts its pixel data in the specified format, and stores it in an array for subsequent operations.
- Open the HEIC file named "filename.heic" using
IOFileStream
. - Load the HEIC image from the file stream into a
HeicImage
object. - Extract pixel data from the HEIC image in the ARGB32 format and store it in an integer array.
Copy and paste the code snippet below into your main file and execute the program.
Read .heic file to int array with Argb32 data
try (IOFileStream fs = new IOFileStream("filename.heic", IOMode.READ))
{
HeicImage image = HeicImage.load(fs);
int[] pixels = image.getInt32Array(openize.heic.decoder.PixelFormat.Argb32);
}
Read HEIC file into BufferedImage in Java and save it to JPEG using Java ImageIO
The following code illustrates how to read an existing HEIC image file, extract its pixel data, and create a BufferedImage object for further processing and saving to JPEG:
- Open the HEIC file named "filename.heic" using
IOFileStream
. - Load the HEIC image from the file stream into a
HeicImage
object. - Extract pixel data from the HEIC image in the ARGB32 format and store it in an array.
- Get the width and height of the HEIC image.
- Create a
BufferedImage
object with the specified width, height, and pixel format. - Write the extracted pixel data to the
BufferedImage
object. - Save the
BufferedImage
object into a JPEG file.
Copy and paste the code snippet below into your main file and execute the program.
Read .heic file to BufferedImage
try (IOFileStream fs = new IOFileStream("filename.heic", IOMode.READ))
{
HeicImage image = HeicImage.load(fs);
int[] pixels = frames.get(key).getInt32Array(PixelFormat.Argb32);
var width = (int)image.Width;
var height = (int)image.Height;
BufferedImage image2 = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
image2.setRGB(0, 0, width, height, pixels, 0, width);
ImageIO.write(image2, "JPEG", new File("output.jpg"));
}
Read HEIC file into BufferedImage in Java and save it to PNG using Java ImageIO
The following code illustrates how to read an existing HEIC image file, extract its pixel data, and create a BufferedImage object for further processing and saving to PNG:
- Open the HEIC file named "filename.heic" using
IOFileStream
. - Load the HEIC image from the file stream into a
HeicImage
object. - Extract pixel data from the HEIC image in the ARGB32 format and store it in an array.
- Get the width and height of the HEIC image.
- Create a
BufferedImage
object with the specified width, height, and pixel format. - Write the extracted pixel data to the
BufferedImage
object. - Save the
BufferedImage
object into a PNG file.
Copy and paste the code snippet below into your main file and execute the program.
Read .heic file to BufferedImage
try (IOFileStream fs = new IOFileStream("filename.heic", IOMode.READ))
{
HeicImage image = HeicImage.load(fs);
int[] pixels = frames.get(key).getInt32Array(PixelFormat.Argb32);
var width = (int)image.Width;
var height = (int)image.Height;
BufferedImage image2 = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
image2.setRGB(0, 0, width, height, pixels, 0, width);
ImageIO.write(image2, "PNG", new File("output.png"));
}
Convert HEIC collection to a set of PNG files programatically in Java
The provided code demonstrates how to programmatically load a HEIC collection image file, convert it to a set of PNG files, and save it using Java. Here's a breakdown of the steps:
- Open the HEIC file named "filename.heic" in read mode using
FileStream
. - Load the HEIC image from the file stream into a
HeicImage
object. - For each frame of the image do the following:
- Retrieve the width and height of the HEIC frame.
- Extract the pixel data from the HEIC frame in the ARGB32 format, storing it in an int array.
- Create a
BufferedImage
object with the specified width, height, DPI, pixel format. - Write the extracted pixel data to the
BufferedImage
object. - Save the
BufferedImage
object into "output.png" file.
Copy and paste the code snippet below into your main file and execute the program.
Convert .heic collection to a set of .png files
try (IOFileStream fs = new IOFileStream("filename.heic", IOMode.READ))
{
HeicImage image = HeicImage.load(fs);
final Map frames = image.getFrames();
for (Long key : frames.keySet())
{
int width = (int)frames.get(key).getWidth();
int height = (int)frames.get(key).getHeight();
int[] pixels = frames.get(key).getInt32Array(PixelFormat.Argb32);
BufferedImage image2 = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
image2.setRGB(0, 0, width, height, pixels, 0, width);
ImageIO.write(image2, "PNG", new File("output"+key+".png"));
}
}
Openize.HEIC offers an intuitive API, comprehensive format support, and seamless integration with Java applications, empowering developers and users alike to effortlessly manage HEIC files. Whether you're converting HEIC files for web usage, archiving iPhone photos to a PC, or sharing them across different platforms, Openize.HEIC simplifies the process, ensuring optimal efficiency and quality at every step.
Explore our GitHub repository to contribute, suggest improvements, and enhance this Open Source API: Openize.HEIC for Java