我目前正在生成多个图像,然后将它们保存为多帧tiff格式。
我使用以下代码来保存tiff文件。
System.Drawing.Imaging.Encoder encoder = System.Drawing.Imaging.Encoder.SaveFlag;
ImageCodecInfo encoderInfo = ImageCodecInfo.GetImageEncoders().First(i => i.MimeType == "image/tiff");
EncoderParameters encoderParameters = new EncoderParameters(1);
encoderParameters.Param[0] = new EncoderParameter(encoder, (long)EncoderValue.MultiFrame);
// Save the first frame of the multi page tiff
Bitmap firstImage = (Bitmap)_imageList[0];
firstImage.Save(System.IO.Directory.GetCurrentDirectory() + @"\ChargeInvoice Images\" + OrderNumber + "_Invoice.tiff", encoderInfo, encoderParameters);
encoderParameters.Param[0] = new EncoderParameter(encoder, (long)EncoderValue.FrameDimensionPage);
// Add the remining images to the tiff
for (int i = 1; i < _imageList.Count; i++)
{
Bitmap img = (Bitmap)_imageList[i];
firstImage.SaveAdd(img, encoderParameters);
}
// Close out the file
encoderParameters.Param[0] = new EncoderParameter(encoder, (long)EncoderValue.Flush);
firstImage.SaveAdd(encoderParameters);
这些TIFF文件有些达到了18页,且文件大小超过了11 MB。
是否有方法可以压缩这些TIFF文件以减小文件大小?
即使失去一些图像质量也没有关系。