How to add signature to image

How to add signature to image

Issue : How to add signature to image.

Tips : To add signature to image, it is needed to use Graphics class and function DrawImage.

Example :

using Aspose.Imaging;
using Aspose.Imaging.Brushes;
using Aspose.Imaging.FileFormats.Png;
using Aspose.Imaging.FileFormats.Svg;
using Aspose.Imaging.FileFormats.Tiff;
using Aspose.Imaging.FileFormats.Tiff.Enums;
using Aspose.Imaging.ImageOptions;
using Aspose.Imaging.Sources;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
string dataDir = templatesFolder;
// Create an instance of Image and load the primary image
using (Aspose.Imaging.Image canvas = Aspose.Imaging.Image.Load(dataDir + "template.tiff"))
{
// Create another instance of Image and load the secondary image containing the signature graphics
using (Aspose.Imaging.Image signature = Aspose.Imaging.Image.Load(dataDir + "template.jpg"))
{
// Create an instance of Graphics class and initialize it using the object of the primary image
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(canvas);
// Call the DrawImage method while passing the instance of secondary image and appropriate location. The following snippet tries to draw the secondary image at the right bottom of the primary image
graphics.DrawImage(signature, new Aspose.Imaging.Point(canvas.Width - signature.Width, canvas.Height - signature.Height));
canvas.Save(dataDir + "result.png", new PngOptions());
}
}
File.Delete(dataDir + "result.png");