.NET 多页 Tiff 与有损压缩

发布于 2024-09-03 19:37:56 字数 230 浏览 12 评论 0原文

我需要一种方法来获取多个 jpg 并将它们转换为单个多页 Tiff。我使用 GDI+ 进行工作,但它仅适用于无损压缩 LZW。这意味着我的 3 个 50KB Jpg 变成了 3MB 多页 Tiff 文件。对于我正在开发的软件来说,这是我无法接受的。

我知道 Tiff 图像格式可以使用 JPG 压缩方案,但 GDI+ 似乎不支持这一点。

如果有人知道如何在 .NET (C#) 或执行此转换的任何组件中执行此操作。

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 conversion.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡看悲欢离合 2024-09-10 19:37:56

BitMiracle LibTiff.net 支持 JPG(以及可能还有所有其他 Tiff 编解码器)以及多页争吵。我已经使用过它,尽管与其他编解码器结合使用,并且获得了非常好的体验;它也经过了良好的测试(包括单元测试)。根据 LGPL 提供。支持也很好(最近发现文件>2GB的问题,我快速响应并更新了代码)

希望这对您有帮助。抱歉,我忍不住对这个组件充满热情,因为它对我帮助很大,而且是免费的。

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.

半枫 2024-09-10 19:37:56

我在 Atalasoft 工作,我们拥有可以轻松完成此操作的 .NET 工具。

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);
        }
    }
}

需要注意的一件事是,TIFF 中有两种 JPEG 压缩方式,一种是标准认可的,另一种是公认的/几乎不能容忍的。后者被称为旧式 JPEG,被固定在 TIFF 上,并且与 TIFF 中的任何其他压缩相比,它是造成更多损坏文件的原因。上面的代码将使用符合标准的 JPEG 压缩。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文