GroupDocs.Merger allows developers to combine multiple PNG documents in the preferred order and save them as a single file.
PNG, Portable Network Graphics, refers to a type of raster image file format that use loseless compression. This file format was created as a replacement of Graphics Interchange Format (GIF) and has no copyright limitations. However, PNG file format does not support animations. PNG file format supports loseless image compression that makes it popular among its users. With the passage of time, PNG has evolved as one of the mostly used image file format.
You can follow the steps below to reference GroupDocs.Merger for Java downloaded from official website Downloads section:
- Unpack zip archive .
- Switch to lib folder.
- Run install.bat (for Windows) or install.sh (for Linux) file to install the library in your local maven repository.
- After this you should add the merger dependency block to your pom.xml project file.
The following example demonstrates how to merge image files in horizontal mode with several lines of Java code:
- Create an instance of Merger class and pass source image file path as a constructor parameter. You may specify absolute or relative file path as per your requirements.
- Create an instance of ImageJoinOptions class and pass enum value of ImageJoinMode as a constructor parameter.
- Add another image file to merge with join method and pass instance of ImageJoinOptions class as a method parameter. Repeat this step for other image documents you want to merge.
- Call Merger class save method and specify the filename for the merged image file as parameter.
// Load the source image file Merger merger = new Merger("c:\sample1.png") // Define image join options with horizontal join mode ImageJoinOptions joinOptions = new ImageJoinOptions(ImageJoinMode.Horizontal); // Add another image file to merge merger.join("c:\sample2.png", joinOptions); // Add next image file to merge merger.join("c:\sample3.png", joinOptions); // Merge image files and save result merger.save("c:\merged.png");
Please find more use-cases and complete Java sources of our backend and frontend examples and try them for free!
GroupDocs.Merger for Java provides an online PNG Merger App, which allows you to try it for free and check its quality and accuracy.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.