2014-03-14 189 views
0

轉換/讀取2頁.tif文件時出現錯誤。什麼是正確的方法呢?將2頁.tif文件轉換爲.jpg

2 page

這裏的錯誤:

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

回答

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