Merge Images in Java
Use Aspose.Slides for Java to merge images in Java applications.
Merge images in Java
Using
Aspose.Slides for Java
, you can merge images and create a PNG result with a few lines of Java code.
Java code for merging images
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
byte[] firstImageData = Files.readAllBytes(Paths.get("image1.png"));
IPPImage firstImage = presentation.getImages().addImage(firstImageData);
slide.getShapes().addPictureFrame(ShapeType.Rectangle, 0, 0, 100, 100, firstImage);
byte[] secondImageData = Files.readAllBytes(Paths.get("image2.png"));
IPPImage secondImage = presentation.getImages().addImage(secondImageData);
slide.getShapes().addPictureFrame(ShapeType.Rectangle, 0, 200, 100, 100, secondImage);
IImage mergedImage = slide.getImage(1f, 1f);
try {
mergedImage.save("merged.png", ImageFormat.Png);
} finally {
mergedImage.dispose();
}
} finally {
presentation.dispose();
}Merge images using Aspose.Slides
Aspose.Slides for Java
is a Java API for creating, editing, converting, and merging presentation content. You can place images into a Presentation and render the combined slide as a PNG image.
How to merge images in Java
- Install Aspose.Slides for Java.
- Add the library as a reference in your project.
- Create a
Presentationinstance. - Load the source images with
Files.readAllBytesandPaths.get. - Render the slide with
getImageand save it withImageFormat.Png.
Built with Aspose.Slides
Merge Image Files Online
The free Aspose.Slides Merger app is built with Aspose.Slides for Java, the same API as the code above. Open it and see what the API can do with your own Image files.
- Runs in your browser, nothing to install.
- See how Aspose.Slides merges files before you write code.
- Upload several Image files and combine them into one.
- Download the merged result as one file.
Merge other files
You can also combine files in other formats to get a single file.