diff options
author | fwarmerdam <fwarmerdam> | 2012-06-06 06:05:29 +0000 |
---|---|---|
committer | fwarmerdam <fwarmerdam> | 2012-06-06 06:05:29 +0000 |
commit | ae704b74ffd943498eff5290d45b4d92d35e1458 (patch) | |
tree | 152961401fa3ec89ee809aeaefb845774ec2e6eb | |
parent | 1c612555b839c370b56e933bc15d0df6376b0b5f (diff) | |
download | libtiff-ae704b74ffd943498eff5290d45b4d92d35e1458.tar.gz |
nicer way to avoid reading data for non-image directories
-rw-r--r-- | tools/tiffinfo.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/tools/tiffinfo.c b/tools/tiffinfo.c index dd8bc79f..ae1a5f62 100644 --- a/tools/tiffinfo.c +++ b/tools/tiffinfo.c @@ -1,4 +1,4 @@ -/* $Id: tiffinfo.c,v 1.20 2012-06-01 23:22:54 fwarmerdam Exp $ */ +/* $Id: tiffinfo.c,v 1.21 2012-06-06 06:05:29 fwarmerdam Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -53,7 +53,7 @@ static int readdata = 0; /* read data in file */ static int stoponerr = 1; /* stop on first read error */ static void usage(void); -static void tiffinfo(TIFF*, uint16, long); +static void tiffinfo(TIFF*, uint16, long, int); static void PrivateErrorHandler(const char* module, const char* fmt, va_list ap) @@ -139,22 +139,19 @@ main(int argc, char* argv[]) if (tif != NULL) { if (dirnum != -1) { if (TIFFSetDirectory(tif, (tdir_t) dirnum)) - tiffinfo(tif, order, flags); + tiffinfo(tif, order, flags, 1); } else if (diroff != 0) { if (TIFFSetSubDirectory(tif, diroff)) - tiffinfo(tif, order, flags); + tiffinfo(tif, order, flags, 1); } else { do { toff_t offset; - tiffinfo(tif, order, flags); + tiffinfo(tif, order, flags, 1); if (TIFFGetField(tif, TIFFTAG_EXIFIFD, &offset)) { if (TIFFReadEXIFDirectory(tif, offset)) { - int old_readdata = readdata; - readdata = 0; - tiffinfo(tif, order, flags); - readdata = old_readdata; + tiffinfo(tif, order, flags, 0); } } } while (TIFFReadDirectory(tif)); @@ -445,10 +442,10 @@ TIFFReadRawData(TIFF* tif, int bitrev) } static void -tiffinfo(TIFF* tif, uint16 order, long flags) +tiffinfo(TIFF* tif, uint16 order, long flags, int is_image) { TIFFPrintDirectory(tif, stdout, flags); - if (!readdata) + if (!readdata || !is_image) return; if (rawdata) { if (order) { |