← All products
Imagise plugin Available

Merger

Combine multiple images on a single canvas.

Imagise.Merger

Overview

Imagise.Merger lets .NET applications create a canvas and draw source images into positioned rectangles using the public image creation and graphics APIs.

What it does

  • Create a combined image canvas
  • Position source images in rectangles
  • Set the canvas background color

Install from NuGet

Run this command from your .NET project directory.

dotnet add package Imagise.Merger

C# example

using System;
using System.Drawing;
using System.IO;
using Imagise.Converter.ImageOptions;
using Imagise.Core.Creator.Source;
using Image = Imagise.Core.Image;

using (var first = Image.Load("first.png"))
using (var second = Image.Load("second.png"))
using (var stream = new MemoryStream())
{
    var options = new PngOptions { Source = new StreamSource(stream) };
    using (var merged = Imagise.Core.Creator.Image.Create(
        options, first.Width + second.Width, Math.Max(first.Height, second.Height)))
    {
        var graphics = new Imagise.Core.Graphics(merged);
        graphics.Clear(Color.White);
        graphics.DrawImage(first, new RectangleF(0, 0, first.Width, first.Height));
        graphics.DrawImage(second,
            new RectangleF(first.Width, 0, second.Width, second.Height));
        merged.Save("merged.png");
    }
}