我有一个使用jpeg压缩的多页tiff。
通过libtiff.net打开文件时,我收到以下错误消息:
JPEGPreDecode:
JPEG strip/tile size exceeds expected dimensions, expected 1164x1, got 1164x826.图像处理失败。文件/目录具有以下标记:
OldSubFileType (1 Short): 1
ImageWidth (1 Long): 1164
ImageLength (1 Long): 826
BitsPerSample (3 Short): 8, 8, 8
Compression (1 Short): JPEG Technote #2
Photometric (1 Short): YCbCr
FillOrder (1 Short): Msb2Lsb
StripOffsets (1 Long): 224
SamplesPerPixel (1 Short): 3
StripByteCounts (1 Long): 109294
XResolution (1 Rational): 200
YResolution (1 Rational): 200
PlanarConfig (1 Short): Contig对于其他jpeg压缩文件,我没有问题。你知道为什么我会得到这个错误吗?为什么它需要1164x1?
发布于 2012-11-25 03:12:47
请确保您的文件设置了ROWSPERSTRIP标签。
如果不设置此标记,JPEG解码器可能会认为图像中条带的高度不正确。
另一种选择是下载source code of LibTiff.Net,在JpgeCodec.cs中的JPEGPreDecode方法的开头设置断点,看看哪里出了问题。最有可能的是,该方法的以下部分导致了编解码器的警告和行为异常:
if (segment_height > td.td_rowsperstrip)
segment_height = td.td_rowsperstrip;您可以更改该方法的这一部分,但更好的做法可能是修复文件。
您也可以尝试自己添加标签(请注意,您需要为每个目录设置标签)。打开图像,检查标签的存在,并尝试使用'SetField‘方法为标签设置正确的值。
using (Tiff image = Tiff.Open(existingTiffName, "a"))
{
for (int i = 0; i < image.NumberOfDirectories(); i++)
{
image.SetDirectory(i);
...
FieldValue[] value = image.GetField(TiffTag.ROWSPERSTRIP);
if (value == null)
{
// ROWSPERSTRIP is not set
image.SetField(TiffTag.ROWSPERSTRIP, heightOfTheImage);
}
...
}
}请注意,您应该在append more中打开图像(为此使用"a"参数)。
https://stackoverflow.com/questions/13476554
复制相似问题