public static void Run()
{
// To get proper output please apply a valid Aspose.Imaging License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx.");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();
TiffOptions outputSettings = new TiffOptions(TiffExpectedFormat.Default);
outputSettings.BitsPerSample = new ushort[] { 1 };
outputSettings.Compression = TiffCompressions.CcittFax3;
outputSettings.Photometric = TiffPhotometrics.MinIsWhite;
outputSettings.Source = new StreamSource(new MemoryStream());
int newWidth = 500;
int newHeight = 500;
string path = dataDir + "AddFramesToTIFFImage_out.tif";
using (TiffImage tiffImage = (TiffImage)Image.Create(outputSettings, newWidth, newHeight))
{
int index = 0;
foreach (var file in Directory.GetFiles(dataDir, "*.jpg"))
{
using (RasterImage ri = (RasterImage)Image.Load(file))
{
ri.Resize(newWidth, newHeight, ResizeType.NearestNeighbourResample);
TiffFrame frame = tiffImage.ActiveFrame;
if (index > 0)
{
frame = new TiffFrame(new TiffOptions(outputSettings) /*ensure options are cloned for each frame*/,
newWidth, newHeight);
// If there is a TIFF image loaded you need to enumerate the frames and perform the following
// Frame = TiffFrame.CreateFrameFrom(sourceFrame, outputSettings);
}
frame.SavePixels(frame.Bounds, ri.LoadPixels(ri.Bounds));
if (index > 0)
{
tiffImage.AddFrame(frame);
}
index++;
}
}
tiffImage.Save(path);
}
}
}