0

转换/读取 2 页 .tif 文件时出现错误。什么是正确的方法?

2 页

这是错误:

ImageMagick.MagickCoderErrorException: Magick: C:\DigitalAssets\sample.TIF: Null count for "Tag 33426" (type 4, writecount -3, passcount 1). `_TIFFVSetField' @ error/tiff.c/TIFFErrors/561
   at ImageMagick.MagickImage.HandleReadException(MagickException exception)
   at ImageMagick.MagickImage.Read(String fileName, MagickReadSettings readSettings)
   at Digital_Asset_Converter_Service.Service.EPSFolderWatcher_Created(Object sender, FileSystemEventArgs e)

这是代码:

string fileName = @"C:\DigitalAssets\sample.tif";
using (MagickImageCollection image = new MagickImageCollection())
    {
        MagickReadSettings settings = new MagickReadSettings();
        // settings.ColorSpace = ColorSpace.RGB;
        settings.Density = new MagickGeometry(300, 300);
        //settings.FrameIndex = 0;
        // settings.FrameCount = 1;

        image.Read(fileName,settings);
    }
4

1 回答 1

1

您的图像包含导致 MagickCoderErrorException 的损坏 tiff 标签。我们对 ImageMagick 进行了更改,允许您忽略特定的 tiff 标签。下面是一个可以防止 MagickCoderErrorException 的示例:

using (MagickImage image = new MagickImage())
{
  image.SetDefine(MagickFormat.Tiff, "ignore-tags", "33426");
  // Or if you want to ignore multiple tags:
  image.SetDefine(MagickFormat.Tiff, "ignore-tags", "33426,33428");

  MagickReadSettings settings = new MagickReadSettings();
  // settings.ColorSpace = ColorSpace.RGB;
  settings.Density = new MagickGeometry(300, 300);

  image.Read(fileName, settings);
}
于 2014-03-19T09:41:20.677 回答