在尝试将多页文档从 tiff 转换为 pdf 时,我遇到了以下问题:
↪ tiff2pdf 0271.f1.tiff -o 0271.f1.pdf
tiff2pdf: No support for 0271.f1.tiff with no photometric interpretation tag.
tiff2pdf: An error occurred creating output PDF file.
有谁知道这是什么原因以及如何解决它?
这是因为多页 tiff 中的一个或多个页面没有设置光度解释标签。这是一个必需的标签,因此这意味着您的 tiff 在技术上是无效的(尽管我敢打赌它们无论如何都可以正常工作)。
要解决此问题,您必须识别没有设置光度解释集的页面(或页面)并进行修复。
要识别页面,您可以简单地运行以下命令:
↪ tiffinfo your-file.tiff
这将为您的 tiff的每一页吐出信息。对于每个好的页面,您会看到如下内容:
TIFF Directory at offset 0x105c0 (67008)
Subfile Type: (0 = 0x0)
Image Width: 1760 Image Length: 2639
Resolution: 300, 300 pixels/inch
Bits/Sample: 1
Compression Scheme: CCITT Group 4
**Photometric Interpretation: min-is-white**
FillOrder: msb-to-lsb
Orientation: row 0 top, col 0 lhs
Samples/Pixel: 1
Rows/Strip: 2639
Planar Configuration: single image plane
Software: ScanFix(TM) Enhanced ImageGear Version: 11.00.024
DateTime: Mon Oct 31 15:11:07 2005
Artist: 1996-2001 AccuSoft Co., All rights reserved
如果您的页面不好,它将缺少该photometric interpretation
部分,您可以通过以下方式修复它:
↪ tiffset -d $page-number -s 262 0 your-file.tiff
请注意,零值是光度解释键的默认值,即 262。您可以在上面的链接中查看此键的其他值。
如果您的 tiff 有很多页面(就像我的那样),您可能无法通过肉眼轻松识别不良页面。在这种情况下,您可以采取蛮力方法,将所有页面的光度解释设置为默认值。
# First, split the tiff into many one-page files
↪ tiffsplit your-file.tiff
# Then, set the photometric interpretation to the default for all pages
↪ find . -name '*.tiff' -exec tiffset -s 262 0 '{}' \;
# Then rejoin the pages
↪ tiffcp *.tiff -o out-file.tiff
大量的虚拟工作,但完成了工作。