Added open option 'h' to avoid reading the first IFD when needed. As per bug

http://bugzilla.remotesensing.org/show_bug.cgi?id=875
This commit is contained in:
Andrey Kiselev 2005-07-01 12:35:18 +00:00
parent 2bc9903a19
commit 40c424104d
3 changed files with 25 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $Id: tif_open.c,v 1.25 2005-06-03 13:41:13 dron Exp $ */
/* $Id: tif_open.c,v 1.26 2005-07-01 12:35:18 dron Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -222,6 +222,7 @@ TIFFClientOpen(
* 'm' disable use of memory-mapped files
* 'C' enable strip chopping support when reading
* 'c' disable strip chopping support
* 'h' read TIFF header only, do not load the first IFD
*
* The use of the 'l' and 'b' flags is strongly discouraged.
* These flags are provided solely because numerous vendors,
@ -296,6 +297,9 @@ TIFFClientOpen(
if (m == O_RDONLY)
tif->tif_flags &= ~TIFF_STRIPCHOP;
break;
case 'h':
tif->tif_flags |= TIFF_HEADERONLY;
break;
}
/*
* Read in TIFF header.
@ -378,6 +382,16 @@ TIFFClientOpen(
tif->tif_flags |= TIFF_MYBUFFER;
tif->tif_rawcp = tif->tif_rawdata = 0;
tif->tif_rawdatasize = 0;
/*
* Sometimes we do not want to read the first directory (for example,
* it may be broken) and want to proceed to other directories. I this
* case we use the TIFF_HEADERONLY flag to open file and return
* immediately after reading TIFF header.
*/
if (tif->tif_flags & TIFF_HEADERONLY)
return (tif);
/*
* Setup initial directory.
*/

View File

@ -1,4 +1,4 @@
/* $Id: tiffiop.h,v 1.35 2005-06-29 10:21:35 dron Exp $ */
/* $Id: tiffiop.h,v 1.36 2005-07-01 12:35:18 dron Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -109,6 +109,8 @@ struct tiff {
#define TIFF_INSUBIFD 0x2000 /* currently writing a subifd */
#define TIFF_UPSAMPLED 0x4000 /* library is doing data up-sampling */
#define TIFF_STRIPCHOP 0x8000 /* enable strip chopping support */
#define TIFF_HEADERONLY 0x10000 /* read header only, do not process */
/* the first directory */
toff_t tif_diroff; /* file offset of current directory */
toff_t tif_nextdiroff; /* file offset of following directory */
toff_t* tif_dirlist; /* list of offsets to already seen */

View File

@ -1,4 +1,4 @@
.\" $Id: TIFFOpen.3tiff,v 1.1 2004-11-11 14:39:16 dron Exp $
.\" $Id: TIFFOpen.3tiff,v 1.2 2005-07-01 12:36:22 dron Exp $
.\"
.\" Copyright (c) 1988-1997 Sam Leffler
.\" Copyright (c) 1991-1997 Silicon Graphics, Inc.
@ -23,7 +23,7 @@
.\" OF THIS SOFTWARE.
.\"
.if n .po 0
.TH TIFFOpen 3TIFF "January 9, 1996" "libtiff"
.TH TIFFOpen 3TIFF "July 1, 2005" "libtiff"
.SH NAME
TIFFOpen, TIFFFdOpen, TIFFClientOpen \- open a
.SM TIFF
@ -203,6 +203,11 @@ strip chopping.
.TP
.B c
Disable the use of strip chopping when reading images.
.TP
.B h
Read TIFF header only, do not load the first image directory. That could be
useful in case of the broken first directory. We can open the file and proceed
to the other directories.
.SH "BYTE ORDER"
The
.SM TIFF