2013.05.15 02:26 "[Tiff] TIFF conversion error", by tiuser Lassei

2013.06.10 09:31 "[Tiff] Detection of corrupted TIFF files bug", by Christos Charalambous

Hi everyone!

I've used this code by LibTIFF to detect if TIFF files in a folder are

corrupted or not. I want to detect images that can be opened but are

corrupted.

This is the code i used to modify to my needs

using System.Windows.Forms;

using BitMiracle.LibTiff.Classic;

namespace BitMiracle.LibTiff.Samples{
    public static class DetermineCorruptPage
    {
        public static void Main()
        {
            using (Tiff image = Tiff.Open(@"Sample Data\127.tif", "r"))
            {
                if (image == null)
                {
                    MessageBox.Show("Could not load incoming image");
                    return;
                }
                int numberOfDirectories = image.NumberOfDirectories();
                for (int i = 0; i < numberOfDirectories; ++i)
                {
                    image.SetDirectory((short)i);

int width = image.GetField(TiffTag.IMAGEWIDTH)[0].ToInt();
int height = image.GetField(TiffTag.IMAGELENGTH)[0].ToInt();

int imageSize = height * width;
int[] raster = new int[imageSize];

                if (!image.ReadRGBAImage(width, height, raster, true))
                {
                    MessageBox.Show("Page " + i + " is corrupted");
                    return;
                }
            }
        }
    }
}}

The problem is that although some of the images are detected correctly as

Kind regards

Chris