Create multipage tiff from set of images
Contents
[
Hide
]
Create multipage tiff from set of images
Issue : Create multipage tiff from set of images.
Tips : To create multipage tiff from set of images AddPage method can be used.
Example :
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 Aspose.Imaging; | |
using Aspose.Imaging.FileFormats.Tiff; | |
using Aspose.Imaging.FileFormats.Tiff.Enums; | |
using Aspose.Imaging.ImageOptions; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
string templatesFolder = @"c:\Users\USER\Downloads\templates\"; | |
string dataDir = templatesFolder; | |
// Load frames | |
var images = LoadImages().ToArray(); | |
// Create TIFF image using the first frame | |
using (var image = new TiffImage(new TiffFrame(images[0]))) | |
{ | |
// Add frames to the TIFF image using the AddPage method | |
for (var index = 1; index < images.Length; index++) | |
{ | |
image.AddPage(images[index]); | |
} | |
// Save TIFF image using options | |
var options = new TiffOptions(TiffExpectedFormat.TiffJpegRgb); | |
image.Save(dataDir + "result.tiff", options); | |
} | |
foreach (RasterImage image in images) | |
{ | |
image.Dispose(); | |
} | |
File.Delete(dataDir + "result.tiff"); | |
IEnumerable<RasterImage> LoadImages() | |
{ | |
foreach (var filePath in new string[] { "template.png", "template.jpg", "template.bmp" }) | |
{ | |
yield return (RasterImage)Image.Load(dataDir + filePath); | |
} | |
} |