How to load large tiff file when memory not enought
Contents
[
Hide
]
How to load large tiff file when there is not enought memory
Issue : Fails to load large tiff file.
Tips : To load large tiff images there can be used memory strategy optimization be specifying buffersizehint property for your PC.
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.Bmp; | |
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; | |
string templatesFolder = @"c:\Users\USER\Downloads\templates\"; | |
string dataDir = templatesFolder; | |
string fileName = Path.Combine(dataDir, "template.tiff"); | |
// Setting a memory limit of 10 megabytes for target loaded image | |
using (Image image = Image.Load(dataDir + "template.tiff", new LoadOptions { BufferSizeHint = 10 })) | |
{ | |
image.Save(dataDir + "output.tiff", new TiffOptions(TiffExpectedFormat.Default)); | |
} | |
using (Image image = Image.Load(dataDir + "template.tiff", new LoadOptions { BufferSizeHint = 10 })) | |
{ | |
image.Save(dataDir + "output.tiff", new TiffOptions(TiffExpectedFormat.TiffCcitRle)); | |
} | |
using (Image image = Image.Load(dataDir + "template.tiff", new LoadOptions { BufferSizeHint = 10 })) | |
{ | |
image.Save(dataDir + "output.tiff", new TiffOptions(TiffExpectedFormat.TiffDeflateRgb)); | |
} | |
using (Image image = Image.Load(dataDir + "template.tiff", new LoadOptions { BufferSizeHint = 10 })) | |
{ | |
image.Save(dataDir + "output.tiff", new TiffOptions(TiffExpectedFormat.TiffJpegYCbCr)); | |
} | |
using (Image image = Image.Load(dataDir + "template.tiff", new LoadOptions { BufferSizeHint = 10 })) | |
{ | |
image.Save(dataDir + "output.tiff", new TiffOptions(TiffExpectedFormat.TiffLzwCmyk)); | |
} | |
using (Image image = Image.Load(dataDir + "template.tiff", new LoadOptions { BufferSizeHint = 10 })) | |
{ | |
image.Save(dataDir + "output.tiff", new TiffOptions(TiffExpectedFormat.TiffNoCompressionRgb)); | |
} | |
File.Delete(dataDir + "output.tiff"); |