不支持旧式 JPEG-in-TIFF 数据的解码 [英] Decoding of old style JPEG-in-TIFF data is not supported

查看:37
本文介绍了不支持旧式 JPEG-in-TIFF 数据的解码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要显示扫描的 tiff 文件的第三页.我使用了代码

I need to display the 3rd page of scanned tiff files. i used the code

TIFFReader reader = new TIFFReader(new File(pathOfFile));    
RenderedImage image = reader.getPage(2);    

它有时会起作用.并显示错误:不支持对旧式 JPEG-in-TIFF 数据进行解码.我用 aspriseTIFF.jar

its sometimes work. and show error : Decoding of old style JPEG-in-TIFF data is not supported. I used aspriseTIFF.jar

然后我如何解决这个问题.请回复.提前致谢

then how i solve this problem. please reply. thanks in advance

推荐答案

您遇到的问题是旧风格"您使用的库不支持 TIFF 格式的 JPEG 压缩(compression == 6).

The problem you have run into is that "old style" JPEG compression in the TIFF format (compression == 6), is not supported in the library you use.

我猜这很常见,因为旧式"JPEG 压缩在 TIFF 中已被弃用,因为它从未被完全指定.由于这种规范不足,不同的供应商以不同的、不兼容的方式实现它.不再支持 TIFF 压缩 7,JPEG.

This is quite common I guess, as "old-style" JPEG compression is deprecated in TIFF, because it was never fully specified. And because of this under-specification, various vendors implemented it in different, incompatible ways. Support was dropped in favor for TIFF compression 7, JPEG.

不幸的是,使用这种压缩的旧 TIFF 文件仍然存在,因此您需要找到另一个库.好消息是您可以使用 ImageIO 和适当的插件.

Unfortunately, old TIFF files using this compression still exists, so you need to find another library. The good news is that you can use ImageIO and a proper plug-in.

使用 TIFF ImageReader 插件,就像我的 TwelveMonkeys ImageIO 开源项目,你应该可以这样做:

Using a TIFF ImageReader plug-in, like the one from my TwelveMonkeys ImageIO open source project, you should be able to do this:

// Create input stream
try (ImageInputStream input = ImageIO.createImageInputStream(file)) {
    // Get the reader
    ImageReader reader = ImageIO.getImageReaders(input).next();

    try {
        reader.setInput(input);

        // Read page 2 of the TIFF file
        BufferedImage image = reader.read(2, null);
    }
    finally {
        reader.dispose();
    }
}

(对于try/finally 样板文件很抱歉,但避免资源/内存泄漏很重要).

(sorry about the try/finally boiler-plate, but it is important to avoid resource/memory leaks).

这篇关于不支持旧式 JPEG-in-TIFF 数据的解码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆