문제

The following (simplified) C# code creates a multi page tiff file:

using System.Windows.Media.Imaging;
var tiffBitmapEncoder = new TiffBitmapEncoder();
using (var ms = new MemoryStream())
{
    tiffBitmapEncoder.Compression = TiffCompressOption.Zip;
    foreach (.....)
    {
        //Generate the image to add to tiff
        .....
        var bitmapSource = new BitmapImage(new Uri(.....));
        tiffBitmapEncoder.Frames.Add(BitmapFrame.Create(bitmapSource));
    }
    tiffBitmapEncoder.Save(ms);
}

The compression seems to be done on each frame/bitmap individually. Therefore the file size grows linearly by the number of frames/bitmaps.

Is there a way to compress the tiff file as a whole?

도움이 되었습니까?

해결책

Is there a way to compress the tiff file as a whole?

Short answer: No. TIFF images are always compressed per image/tile/strip.

Small print: It's possible for JPEG-encoded TIFF files to share tables, this could potentially perform better than linear growth, but I don't think this is what you are looking for.

You can of course create an uncompressed TIFF file, and compress it all using gz, zip or similar tools. However, it won't be a TIFF file any more. And I doubt it will compress better than TIFF with ZIP/Deflate + Predictor.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top