Merge images

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Merger MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-merger -- dnx GroupDocs.Merger.Mcp --yes
Folders, licensing and more →

How to merge image files in C#

GroupDocs.Merger allows developers to combine multiple JPG documents in the preferred order and save them as a single file. You will not spend your time doing these operations manually on desktop software. With GroupDocs.Merger it is possible to combine image documents of any JPG, PNG or BMP extensions.

The following example demonstrates how to merge image files 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.
  • 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
using (Merger merger = new Merger(@"c:\sample1.jpg"))
{
    // Define image join options with vertical join mode
    ImageJoinOptions joinOptions = new ImageJoinOptions(ImageJoinMode.Vertical);
    // Add another image file to merge
    merger.Join(@"c:\sample2.jpg", joinOptions);
    // Merge image files and save result
    merger.Save(@"c:\merged.jpg");
}
Warning
Joining an image into a document format it cannot be joined into (for example, a PNG image into a DOCX document) throws FileTypeNotSupportedException (“Joining ‘Png’ into ‘Docx’ is not supported”).

Merge different image file formats

This section describes how to merge different image file formats using GroupDocs.Merger API. Please look at the articles listed below:

Code Examples

Please find more use-cases and complete C# sources of our backend and frontend examples and try them for free!

Merge Images Live Demo

GroupDocs.Merger offers the following free online tools to test its quality and accuracy: