Created
January 21, 2024 17:52
Convenient tools to create image album from several images or photos, aka multi-frame or muti-page image. Such composition is supported for wide range of input image formats and several popular output mulit page formats aka pdf, tiff, dicom.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Aspose.Imaging; | |
using Aspose.Imaging.FileFormats.Pdf; | |
namespace CSharpTutorials | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
if(args.Lenght<3) | |
{ | |
Console.WriteLine("Please specify inpur folder with images to merge and "); | |
Console.WriteLine("wildcard mask of the input images (i.e. *.png or *.jpg) and"); | |
Console.WriteLine("output folder to create image album"); | |
return; | |
} | |
// Valid image album plug-in license use example | |
Metered metered = new Metered(); | |
metered.SetLicense("***********", // public key | |
"***********" // private key | |
); | |
string OutputDirectory = Path.Combine(TestDirectory, "ImageAlbum"); | |
if (!Directory.Exists(OutputDirectory)) | |
{ | |
Directory.CreateDirectory(OutputDirectory); | |
} | |
var images = new List<Image>(); | |
foreach (var fileName in Directory.GetFiles(TestDirectory, "*.png")) | |
{ | |
var image = Image.Load(fileName); | |
images.Add(image); | |
} | |
try | |
{ | |
var outputPath = Path.Combine(OutputDirectory, "image_album.pdf"); | |
MakeAlbum(images, new PdfOptions(), outputPath); | |
} | |
finally | |
{ | |
images.ForEach(image => image.Dispose()); | |
} | |
} | |
void MakeAlbum(List<Image> images, ImageOptionsBase imageOptions, string outputPath) | |
{ | |
using (var image = Image.Create(images.ToArray())) | |
{ | |
image.Save(outputPath, imageOptions); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment