开发者

.NET Multipage Tiff with Lossy Compression

开发者 https://www.devze.com 2023-01-02 06:56 出处:网络
I need a way to take several jpgs and convert them into a single multi page Tiff.I have that working using GDI+ however it only works with the compression LZW which is lossless.This means that my 3 50

I need a way to take several jpgs and convert them into a single multi page Tiff. I have that working using GDI+ however it only works with the compression LZW which is lossless. This means that my 3 50KB Jpgs turn into 3MB multipage Tiff file. This is not something I can accept for the software that I am working on.

I know that Tiff Image format can use a JPG compression scheme but GDI+ does not seem to support this.

If anyone knows how to do this in .NET (C#) or of any component that does this conversi开发者_如何学Con.


BitMiracle LibTiff.net supports JPG (along along with propably all other Tiff codecs) as well as multipage tiffs. I have used it, though combined with other codecs, and had very good experiences with it; it is also well tested (unit tests included). Available under LGPL. Support is also very good (recently found an issue in files >2GB and I rapid response and updated code)

Hope this helps you. Sorry, I can't help being enthusiastic about the component as it helped me a great deal and is free.


I work for Atalasoft and we have .NET tools that will do that easily.

public void CombineIntoTiff(string outputTiff, params string[] inputFiles)
{
    using (FileStream stm = new FileStream(outputTiff, FileMode.Create)) {
        TiffEncoder enc = new TiffEncoder();
        enc.Compression = TiffCompression.JpegCompression;
        enc.Append = true;
        foreach (string file in inputFiles) {
            AtalaImage image = null;
            try { image = new AtalaImage(file); } catch { continue; }
            enc.Save(image);
        }
    }
}

One thing to be aware of is that there are two flavors of JPEG compression in TIFF, one that is sanctioned by the standard and one that is acknowledged/barely tolerated. The latter, referred to as old-style JPEG, was bolted onto TIFF and is the cause of more broken files than any other compression in TIFF. The above code will use the standard compliant JPEG compression.

0

精彩评论

暂无评论...
验证码 换一张
取 消