AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2011.09.15 12:36 "Re: [Tiff] TIFFOpen fails on file with large image size.", by
2011.09.15 01:19 "[Tiff] TIFFOpen fails on file with large image size.", by DonM
2011.09.15 11:08 "Re: [Tiff] TIFFOpen fails on file with large image size.", by DonM
2011.09.16 01:58 "Re: [Tiff] TIFFOpen fails on file with large image size.", by DonM

2011.09.15 12:36 "Re: [Tiff] TIFFOpen fails on file with large image size.", by

Hi Don,

I made a tiny standalone version of your program for testing:

-----------
/*

   compile with

        gcc -g -Wall try73.c -ltiff

 */

#include <stdlib.h>
#include <stdio.h>

#include <tiffio.h>

int
main (int argc, char **argv)
{
  const int width = 800;
  const int height = 800;
  const int bytespersample = 2;
  const tsize_t size = width * height * bytespersample;
  const int framecount = 100;

  tdata_t *buf;
  int i;
  TIFF *tif;
  tsize_t n;

  buf = calloc (size, 1);

  if (!(tif = TIFFOpen ("testimage.tiff", "w")))
    perror ("unable to open for write");

  for (i = 0; i < framecount; i++)
    {

      TIFFSetField (tif, TIFFTAG_IMAGEWIDTH, width);
      TIFFSetField (tif, TIFFTAG_IMAGELENGTH, height);
      TIFFSetField (tif, TIFFTAG_BITSPERSAMPLE, 8 * bytespersample);
      TIFFSetField (tif, TIFFTAG_SAMPLESPERPIXEL, 1);
      TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
      TIFFSetField (tif, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);
      TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
      TIFFSetField (tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
      TIFFSetField (tif, TIFFTAG_ROWSPERSTRIP, height);

      if ((n = TIFFWriteEncodedStrip (tif, 0, buf, size)) != size)
        perror ("unable to write data");
      if (!TIFFWriteDirectory (tif))
        perror ("unable to write directory");
    }

  TIFFClose (tif);
  free (buf);

  return 0;
}
----------------------

On Ubuntu 11.04 with libtiff 3.9.4 this runs without error, and passes valgrind (the memory access checker). It takes 0.8s on my 5 year old desktop machine and makes a 120mb file. I can read frames out of this file without error.

Could it be a problem with the way your libtiff was compiled? Did you build it yourself and, if you did, how did you configure it? You may need to patch it to enable tif_win32.c. For tiff4beta6 I use this patch:

http://www.vips.ecs.soton.ac.uk/supported/7.22/win32/tiff4.0.0beta6.patch

I don't know if there are any compiler flags which might also need checking.

John