GroupDocs.Merger allows developers to combine multiple PNG documents in the preferred order and save them as a single file.
About PNG File Format
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.
Download and Configure
Use the downloads section to download API DLLs or MSI installer or NuGet:
PM>Install-PackageGroupDocs.Merger
Source PNG images
How to merge PNG files in horizontal mode
The following example demonstrates how to merge image files in horizontal mode with several lines of C# 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.
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 fileusing(Mergermerger=newMerger(@"c:\sample1.png")){// Define image join options with horizontal join modeImageJoinOptionsjoinOptions=newImageJoinOptions(ImageJoinMode.Horizontal);// Add another image file to mergemerger.Join(@"c:\sample2.png",joinOptions);// Add next image file to mergemerger.Join(@"c:\sample3.png",joinOptions);// Merge image files and save resultmerger.Save(@"c:\merged.png");}