Reduce file size in tiff
Contents
[
Hide
]
Reduce file size in tiff
Issue : Reduce file size in tiff.
Tips : To reduce file size in tiff there can be used Jpeg compression.
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.FileFormats.Bmp; | |
using Aspose.Imaging.FileFormats.Dicom; | |
using Aspose.Imaging.FileFormats.Emf; | |
using Aspose.Imaging.FileFormats.Jpeg; | |
using Aspose.Imaging.FileFormats.Jpeg2000; | |
using Aspose.Imaging.FileFormats.Png; | |
using Aspose.Imaging.FileFormats.Psd; | |
using Aspose.Imaging.FileFormats.Tiff.Enums; | |
using Aspose.Imaging.ImageOptions; | |
using Aspose.Imaging.Masking; | |
using Aspose.Imaging.Masking.Options; | |
using Aspose.Imaging.Masking.Result; | |
using Aspose.Imaging.Sources; | |
using Aspose.Imaging; | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
string templatesFolder = @"c:\Users\USER\Downloads"; | |
CompressTiff(); | |
void CompressTiff() | |
{ | |
var inputFile = Path.Combine(templatesFolder, $"template.tiff"); | |
var outputFile = Path.Combine(templatesFolder, $"compressed.tiff"); | |
using (var image = Image.Load(inputFile)) | |
{ | |
image.Save(outputFile, new Aspose.Imaging.ImageOptions.TiffOptions(TiffExpectedFormat.Default) | |
{ | |
Photometric = TiffPhotometrics.Ycbcr, | |
Compression = TiffCompressions.Jpeg, | |
BitsPerSample = new ushort[] { 8, 8, 8 } | |
}); | |
} | |
File.Delete(outputFile); | |
} |