AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2002.10.11 07:39 "2 GB limit ?", by Frithjof Barner
2002.10.11 13:30 "Re: 2 GB limit ?", by Frank Warmerdam
2002.10.11 14:42 "Re: 2 GB limit ?", by Andrey Kiselev
2002.10.12 16:06 "AW: 2 GB limit ?", by Frithjof Barner

2002.10.11 07:39 "2 GB limit ?", by Frithjof Barner

Hi,

Is there a 2GB limit in tiff-v3.5.7 version 20011128?

My linux ext2 file system supports larger files but I am not able to write an RGB TIFF greater than 2 GB.

cassini:> ./a.out
TIFF test, version 20011128

TIFFAppendToStrip: test_tiff.tif: Write error at scanline 682.

Can't write raw strip
cassini:> dd if=/dev/zero of=test_tiff.bin bs=1048576 count=3000
3000+0 records in
3000+0 records out
cassini:> ls -la test*

-rw-r--r--    1 barner   users    3145728000 Oct  9 16:40 test_tiff.bin
-rw-r--r--    1 barner   users    2147483647 Oct  9 16:32 test_tiff.tif

The code for a.out is below. Is there a limit or do I make something wrong? Are there any work arounds?

Thanks

Frithjof

#include <stdio.h>
#include <tiffio.h>

#define NCOLS (uint32)1024 * (uint32)1024       /* 1MB*/ 

#define NROWS (uint32)683             /*  682 works, 683 does not work*/

/*2GB > (1024*1024 cols * 3bands * 682 rows )*/
/*2GB < (1024*1024 cols * 3bands * 683 rows )*/

int main()
{
   TIFF* tif;

   unsigned char line_r[NCOLS];
   unsigned char line_g[NCOLS];
   unsigned char line_b[NCOLS];
   uint32 r;

   fprintf(stdout, "TIFF test, version %d\n",TIFFLIB_VERSION);

   tif=TIFFOpen("test_tiff.tif", "w");
   if (!tif)
   {
       TIFFError("test_tiff.tif","Can not open output image");
       exit(-1);
   }

   TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, (uint32) NCOLS);
   TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (uint32) NROWS);

   TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3);
   TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE,   8);
   TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP,    1);

   TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_SEPARATE);

   TIFFSetField(tif, TIFFTAG_PHOTOMETRIC,  PHOTOMETRIC_RGB      );
   TIFFSetField(tif, TIFFTAG_COMPRESSION,  COMPRESSION_NONE     );

   for (r=0; r<NROWS; r++)
   {

         if ((TIFFWriteRawStrip(tif, r,             line_r, NCOLS)<0) ||
             (TIFFWriteRawStrip(tif, NROWS+r,       line_g, NCOLS)<0) ||
             (TIFFWriteRawStrip(tif, NROWS+NROWS+r, line_b, NCOLS)<0) )

         {
            fprintf(stderr, "Can't write raw strip\n");
            exit(-1);
         }
   }

   TIFFClose(tif);
   return(0);
}

euromap GmbH, Kalkhorstweg 53, D-17235 Neustrelitz, Germany Tel: +49 (0)3981/4883-13, Fax: +49 (0)3981/4883-20 mailto:barner@euromap.de, http://www.euromap.de