summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--ChangeLog94
-rw-r--r--Makefile.vc2
-rw-r--r--SConstruct2
-rw-r--r--archive/tools/bmp2tiff.c2
-rw-r--r--configure.ac6
-rw-r--r--configure.com10
-rw-r--r--contrib/addtiffo/tif_overview.c4
-rw-r--r--contrib/pds/tif_pdsdirwrite.c2
-rw-r--r--contrib/tags/README2
-rw-r--r--contrib/win_dib/README.Tiffile2
-rw-r--r--contrib/win_dib/README.tiff2dib4
-rw-r--r--contrib/win_dib/Tiffile.cpp2
-rw-r--r--contrib/win_dib/tiff2dib.c4
-rw-r--r--html/internals.html2
-rw-r--r--html/libtiff.html2
-rw-r--r--html/man/TIFFDataWidth.3tiff.html2
-rw-r--r--html/man/TIFFReadRGBAImage.3tiff.html2
-rw-r--r--html/v3.4beta007.html2
-rw-r--r--html/v3.4beta016.html2
-rw-r--r--html/v3.4beta028.html2
-rw-r--r--html/v3.5.7.html4
-rw-r--r--html/v3.6.0.html4
-rw-r--r--html/v3.6.1.html6
-rw-r--r--html/v3.7.0.html2
-rw-r--r--html/v3.7.0alpha.html2
-rw-r--r--html/v3.7.0beta.html2
-rw-r--r--html/v3.7.0beta2.html2
-rw-r--r--html/v3.7.1.html2
-rw-r--r--html/v3.7.2.html2
-rw-r--r--html/v3.7.3.html2
-rw-r--r--html/v3.7.4.html2
-rw-r--r--html/v3.8.0.html6
-rw-r--r--html/v3.8.1.html2
-rw-r--r--html/v3.8.2.html2
-rw-r--r--html/v3.9.0.html2
-rw-r--r--html/v3.9.0beta.html4
-rw-r--r--html/v3.9.1.html2
-rw-r--r--html/v3.9.2.html2
-rw-r--r--html/v3.9.3.html2
-rw-r--r--html/v3.9.4.html2
-rw-r--r--html/v3.9.5.html2
-rw-r--r--html/v4.0.0.html2
-rw-r--r--html/v4.0.4beta.html2
-rw-r--r--html/v4.0.7.html2
-rw-r--r--html/v4.0.8.html2
-rw-r--r--html/v4.0.9.html2
-rw-r--r--libtiff/tif_config.h-vms2
-rw-r--r--libtiff/tif_config.vc.h2
-rw-r--r--libtiff/tif_config.wince.h2
-rw-r--r--libtiff/tif_dir.c2
-rw-r--r--libtiff/tif_vms.c2
-rw-r--r--libtiff/tiffconf.h-vms4
-rw-r--r--libtiff/tiffconf.h.cmake.in4
-rw-r--r--libtiff/tiffconf.h.in4
-rw-r--r--libtiff/tiffconf.vc.h4
-rw-r--r--libtiff/tiffconf.wince.h4
-rw-r--r--man/TIFFDataWidth.3tiff2
-rw-r--r--man/TIFFReadRGBAImage.3tiff2
-rw-r--r--man/tiffcrop.112
-rw-r--r--nmake.opt2
-rw-r--r--test/custom_dir_EXIF_231.c2795
-rw-r--r--test/defer_strile_writing.c2
-rw-r--r--test/raw_decode.c4
-rw-r--r--tools/CMakeLists.txt2
-rw-r--r--tools/thumbnail.c6
-rw-r--r--tools/tiff2ps.c20
-rw-r--r--tools/tiffcrop.c10
68 files changed, 1553 insertions, 1552 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 23005911..ea8f62d1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -634,7 +634,7 @@ set(USE_WIN32_FILEIO ${win32_io})
# Orthogonal features
# Strip chopping
-option(strip-chopping "strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of specified size to reduce memory usage)" ON)
+option(strip-chopping "strip chopping (whether or not to convert single-strip uncompressed images to multiple strips of specified size to reduce memory usage)" ON)
set(TIFF_DEFAULT_STRIP_SIZE 8192 CACHE STRING "default size of the strip in bytes (when strip chopping is enabled)")
set(STRIPCHOP_DEFAULT)
diff --git a/ChangeLog b/ChangeLog
index 452dcb3a..d1caf02e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -469,7 +469,7 @@
see #17
tiffmedian: shopw usage on stdout when -h is used.
- aslo use EXIT_SUCCESS/EXIT_FAILURE
+ also use EXIT_SUCCESS/EXIT_FAILURE
see #17
tiffinfo: print usage on stdout when -h is used.
@@ -674,7 +674,7 @@
2020-03-27 Thomas Bernard <miniupnp@free.fr>
tiff2pdf: fix "raw" copy of Deflate streams.
- The Predictor parametter was not copied from the source tiff to the PDF.
+ The Predictor parameter was not copied from the source tiff to the PDF.
fixes #48 / http://bugzilla.maptools.org/show_bug.cgi?id=2442
2020-03-26 Thomas Bernard <miniupnp@free.fr>
@@ -982,7 +982,7 @@
- EXIF_GPS_upgrade rebased onto c8c5309b765ef4ff097d2aaffbdb8f403db8967d (Merge branch 'Rational2DoublePrecision_correction' into 'master')
and adapted:
- tif_dirinfo.c: All rational tags set to TIFF_SETGET_FLOAT but only the GPSTAG_ tags set to TIFF_SETGET_DOUBLE.
- - custom_dir_EXIF_231.c: Editorials amended and gcc warnigs fixed.
+ - custom_dir_EXIF_231.c: Editorials amended and gcc warnings fixed.
- CMakeLists.txt: add_test(NAME "custom_dir_EXIF_231" COMMAND "custom_dir_EXIF_231") added.
2020-03-07 Even Rouault <even.rouault@spatialys.com>
@@ -1006,7 +1006,7 @@
fix #55
http://bugzilla.maptools.org/show_bug.cgi?id=2505
- Patch originally submited by Ludolf Holzheid <ludolf.holzheid@gmx.de>
+ Patch originally submitted by Ludolf Holzheid <ludolf.holzheid@gmx.de>
2020-03-06 Even Rouault <even.rouault@spatialys.com>
@@ -1129,7 +1129,7 @@
2020-02-29 Su_Laus <sulau@freenet.de>
- tif_dirwrite.c: bugfix DoubleToSrational(), which returns plain signed interger values always as unsigned rationals. Add a test into rational_precision2double.c for "-1.0" and some editorials in tif_dirwrite.c. (code is related to 6df997c786928757caea0dd68d26ea5f098f49df changes).
+ tif_dirwrite.c: bugfix DoubleToSrational(), which returns plain signed integer values always as unsigned rationals. Add a test into rational_precision2double.c for "-1.0" and some editorials in tif_dirwrite.c. (code is related to 6df997c786928757caea0dd68d26ea5f098f49df changes).
2020-02-29 Even Rouault <even.rouault@spatialys.com>
@@ -1174,7 +1174,7 @@
Rational with Double Precision Upgrade.
Unfortunately, custom rational tags (TIFF_RATIONAL with field_bit=FIELD_CUSTOM) are defined as TIFF_SETGET_DOUBLE
- but for the reading interface and LibTiff internally they are stored ALLWAYS as floating point SINGLE precision.
+ but for the reading interface and LibTiff internally they are stored ALWAYS as floating point SINGLE precision.
Double precision custom rational tags are not supported by LibTiff.
For the GPS tags in WGS84 a higher accuracy / precision is needed.
@@ -1269,7 +1269,7 @@
raw2tiff: avoid divide by 0.
fixes #151 / http://bugzilla.maptools.org/show_bug.cgi?id=2839
- first memcmp() lines before computing corellation
+ first memcmp() lines before computing correlation
and always avoid divide by 0 anyway
2020-02-09 Even Rouault <even.rouault@spatialys.com>
@@ -1294,7 +1294,7 @@
tiffcrop.c:4027:20: runtime error: left shift of 190 by 24 places cannot be represented in type 'int'
C treats (byte << 24) as an int expression.
- casting explicitely to unsigned type uint32 avoids the problem.
+ casting explicitly to unsigned type uint32 avoids the problem.
the same issue has been fixed elsewhere with a24213691616e7cd35aa3e2805493de80c7e4fcf
@@ -1523,7 +1523,7 @@
2019-08-25 Even Rouault <even.rouault@spatialys.com>
- JPEG: avoid use of unintialized memory on corrupted files.
+ JPEG: avoid use of uninitialized memory on corrupted files.
Follow-up of cf3ce6fab894414a336546f62adc57f02590a22c
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16602
Credit to OSS Fuzz
@@ -1587,7 +1587,7 @@
signed), which was especially easily triggered on 32-bit builds (with recent
enough compilers that assume that signed multiplication cannot overflow, since
this is undefined behaviour by the C standard). The original issue which lead to
- this fix was trigged from tif_fax3.c
+ this fix was triggered from tif_fax3.c
There were also unsafe (implementation defied), and broken in practice on 64bit
builds, ways of checking that a uint64 fits of a (signed) tmsize_t by doing
@@ -1660,7 +1660,7 @@
- Discussion in https://gitlab.com/libtiff/libtiff/merge_requests/39
- http://bugzilla.maptools.org/show_bug.cgi?id=2540
- Comments and indention adapted.
+ Comments and indentation adapted.
Preparation to rebase onto master
@@ -1680,7 +1680,7 @@
[00:02:58] -- CMAKE_HOST_SYSTEM_PROCESSOR set to AMD64
[00:02:58] -- HOST_FILLORDER set to FILLORDER_MSB2LSB
- Ther reason is that we match the "amd64.*" lowercase string whereas
+ The reason is that we match the "amd64.*" lowercase string whereas
CMAKE_HOST_SYSTEM_PROCESSOR is set to AMD64 uppercase.
2019-07-09 Even Rouault <even.rouault@spatialys.com>
@@ -1690,13 +1690,13 @@
2019-07-09 Even Rouault <even.rouault@spatialys.com>
Merge branch 'fix_chromium_925269' into 'master'
- OJPEG: avoid use of unintialized memory on corrupted files
+ OJPEG: avoid use of uninitialized memory on corrupted files
See merge request libtiff/libtiff!86
2019-07-05 Even Rouault <even.rouault@spatialys.com>
- OJPEG: avoid use of unintialized memory on corrupted files.
+ OJPEG: avoid use of uninitialized memory on corrupted files.
Fixes https://bugs.chromium.org/p/chromium/issues/detail?id=925269
Patch from Lei Zhang with little adaptations.
@@ -1849,12 +1849,12 @@
arrays are only loaded when first accessed. This can speed-up the opening
of files stored on the network when just metadata retrieval is needed.
This mode has been used for years by the GDAL library when compiled with
- its embeded libtiff copy.
+ its embedded libtiff copy.
To avoid potential out-of-tree code (typically codecs) that would use
the td_stripbytecount and td_stripoffset array inconditionnaly assuming they
have been loaded, those have been suffixed with _p (for protected). The
- use of the new functions mentionned below is then recommended.
+ use of the new functions mentioned below is then recommended.
Another addition of this commit is the capability of loading only the
values of the offset/bytecount of the strile of interest instead of the
@@ -1870,7 +1870,7 @@
if a strile is present or not without decompressing the data, or updating
an existing sparse file.
They will also be used to enable a future enhancement where client code can entirely
- skip bytecount loading in some situtations
+ skip bytecount loading in some situations
A new test/defer_strile_loading.c test has been added to test the above
capabilities.
@@ -2141,8 +2141,8 @@
Also the values were not properly calculated. It should be
255-x, 15-x, 3-x for bps 8, 4, 2.
- But anyway it is easyer to invert all bits as 255-x = ~x, etc.
- (substracting from a binary number composed of all 1 is like inverting
+ But anyway it is easier to invert all bits as 255-x = ~x, etc.
+ (subtracting from a binary number composed of all 1 is like inverting
the bits)
2019-02-11 Thomas Bernard <miniupnp@free.fr>
@@ -2670,7 +2670,7 @@
Merge branch 'zstd'
- Add warning about COMPRESSION_ZSTD not being officialy registered.
+ Add warning about COMPRESSION_ZSTD not being officially registered.
2018-02-14 Even Rouault <even.rouault@mines-paris.org>
@@ -2900,7 +2900,7 @@
result, we end up writing past the end of the buffer.
There are also some related issues that this also fixes. For example,
- TIFFGetField can return uninitalized pointer values, and the logic to
+ TIFFGetField can return uninitialized pointer values, and the logic to
detect a N=3 vs N=1 transfer function seemed rather strange.
It is also strange that we declare the transfer functions to be of type
@@ -3315,7 +3315,7 @@
scans and not interleavedin a single one, needs to allocate memory (or
backing store) for the whole strip/tile.
See http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf
- This limitation may be overriden by setting the
+ This limitation may be overridden by setting the
LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC environment variable, or recompiling
libtiff with a custom value of TIFF_LIBJPEG_LARGEST_MEM_ALLOC macro.
@@ -3598,7 +3598,7 @@
* libtiff/tif_jpeg.c: only run JPEGFixupTagsSubsampling() if the
YCbCrSubsampling tag is not explicitly present. This helps a bit to reduce
- the I/O amount when te tag is present (especially on cloud hosted files).
+ the I/O amount when the tag is present (especially on cloud hosted files).
2017-01-14 Even Rouault <even.rouault at spatialys.com>
@@ -3839,7 +3839,7 @@
2016-12-03 Even Rouault <even.rouault at spatialys.com>
* libtiff/tif_dirread.c: modify ChopUpSingleUncompressedStrip() to
- instanciate compute ntrips as TIFFhowmany_32(td->td_imagelength, rowsperstrip),
+ instantiate compute ntrips as TIFFhowmany_32(td->td_imagelength, rowsperstrip),
instead of a logic based on the total size of data. Which is faulty is
the total size of data is not sufficient to fill the whole image, and thus
results in reading outside of the StripByCounts/StripOffsets arrays when
@@ -3863,7 +3863,7 @@
2016-12-02 Even Rouault <even.rouault at spatialys.com>
- * tools/tiffcp.c: avoid uint32 underflow in cpDecodedStrips that
+ * tools/tiffcp.c: avoid uint32 underflow in cpDecodedStrips that
can cause various issues, such as buffer overflows in the library.
Reported by Agostino Sarubbo.
Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2598
@@ -4305,7 +4305,7 @@
* libtiff/tif_write.c: TIFFWriteEncodedStrip() and TIFFWriteEncodedTile()
should return -1 in case of failure of tif_encodestrip() as documented
* libtiff/tif_dumpmode.c: DumpModeEncode() should return 0 in case of
- failure so that the above mentionned functions detect the error.
+ failure so that the above mentioned functions detect the error.
2015-12-06 Even Rouault <even.rouault at spatialys.com>
@@ -4328,7 +4328,7 @@
2015-11-22 Even Rouault <even.rouault at spatialys.com>
* libtiff/*.c: fix typos in comments (patch by Kurt Schwehr)
-
+
2015-11-22 Even Rouault <even.rouault at spatialys.com>
* libtiff/*.c: fix MSVC warnings related to cast shortening and
@@ -4896,7 +4896,7 @@
2014-12-27 Even Rouault <even.rouault@spatialys.com>
* libtiff/tif_dir.c: in TIFFDefaultDirectory(), reset any already existing
- extented tags installed by user code through the extender mechaninm before
+ extended tags installed by user code through the extender mechanism before
calling the extender callback (GDAL #5054)
2014-12-26 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
@@ -4999,14 +4999,14 @@
cpStripToTile() (called from writeBufferToContigTiles).
Note that the resulting TIFF file would be scrambled even
if tiffcp wouldn't crash, since the output file would contain
- RGB data intepreted as subsampled YCbCr values.
+ RGB data interpreted as subsampled YCbCr values.
This patch fixes the problem by forcing RGB space on the output
TIF if the input is JPEG-encoded and output is *not* JPEG-encoded.
Author: Tomasz Buchert <tomasz.buchert@inria.fr>
2014-12-21 Even Rouault <even.rouault@spatialys.com>
- Fix various crasher bugs on fuzzed images.
+ Fix various crash bugs on fuzzed images.
* libtiff/tif_dir.c: TIFFSetField(): refuse to set negative values for
TIFFTAG_XRESOLUTION and TIFFTAG_YRESOLUTION that cause asserts when writing
the directory
@@ -5343,7 +5343,7 @@
* libtiff 4.0.2 released.
- * tools/tif2pdf.c, tools/tifdump.c: avoid unitialized variable
+ * tools/tif2pdf.c, tools/tifdump.c: avoid uninitialized variable
warnings with clang.
2012-06-15 Tom Lane <tgl@sss.pgh.pa.us>
@@ -6990,7 +6990,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic
Added support for a TIFF_PTRDIFF_T type to use when doing pointer arithmetic.
Added support for a TIFF_SSIZE_T in order to return memory sizes but still
allow returning -1 for errors.
- * libtiff/tiffconf.vc.h: Add porting type defintions for WIN32.
+ * libtiff/tiffconf.vc.h: Add porting type definitions for WIN32.
2007-06-25 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
@@ -7125,7 +7125,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic
* libtiff/tif_config.wince.h: Added configuration header for WinCE.
* libtiff/tiffconf.wince.h: Ported old configuration header for WinCE.
* libtiff/tif_wince.c: Added WinCE-specific implementation of some
- functons from tif_win32.c.
+ functions from tif_win32.c.
* libtiff/tif_win32.c: Disabled some functions already reimplemented in tif_wince.c.
* libtiff/tiffiop.h, port/lfind.c: Added conditional include of some
standard header files for Windows CE build.
@@ -7369,7 +7369,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic
* libtiff/tif_jpeg.c: strip size related bugfix in encode raw
- * libtiff/tif_strip.c: temporarilly added two new versions of
+ * libtiff/tif_strip.c: temporarily added two new versions of
TIFFScanlineSize
- TIFFNewScanlineSize: proposed new version, after all related
issues and side-effects are sorted out
@@ -7429,7 +7429,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic
2006-03-16 Andrey Kiselev <dron@ak4719.spb.edu>
- * libtiff/tiffiop.h: Added decalration for
+ * libtiff/tiffiop.h: Added declaration for
_TIFFSetDefaultCompressionState().
* libtiff/{tif_jpeg.c, tif_fax3.c, tif_zip.c, tif_pixarlog.c,
@@ -7759,7 +7759,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic
http://bugzilla.remotesensing.org/show_bug.cgi?id=1003
- * libtiff/tif_dirinfo.c: Correctly yse bsearch() and lfind()
+ * libtiff/tif_dirinfo.c: Correctly use bsearch() and lfind()
functions as per bug
http://bugzilla.remotesensing.org/show_bug.cgi?id=1008
@@ -7804,7 +7804,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic
http://bugzilla.remotesensing.org/show_bug.cgi?id=977
- * tools/tiffsplit.c: Copy fax related fields over splitted parts
+ * tools/tiffsplit.c: Copy fax related fields over split parts
as per bug
http://bugzilla.remotesensing.org/show_bug.cgi?id=983
@@ -7986,12 +7986,12 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic
2005-06-07 Andrey Kiselev <dron@ak4719.spb.edu>
* contrib/addtiffo/tif_ovrcache.c: Properly extract tile/strip size;
- use pixel sized shift in contigous case.
+ use pixel sized shift in contiguous case.
2005-06-06 Andrey Kiselev <dron@ak4719.spb.edu>
* contrib/addtiffo/{tif_overview.c, tif_ovrcache.c, tif_ovrcache.h}:
- Make overviews working for contiguos images.
+ Make overviews working for contiguous images.
2005-06-03 Andrey Kiselev <dron@ak4719.spb.edu>
@@ -8421,7 +8421,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic
http://bugzilla.remotesensing.org/show_bug.cgi?id=697
- * libtiff/tif_config.in.vc: Removed unneded definitions for
+ * libtiff/tif_config.in.vc: Removed unneeded definitions for
read/open/close/lseek functions to fix the
http://bugzilla.remotesensing.org/show_bug.cgi?id=680
@@ -9280,7 +9280,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic
* man/tiff2pdf.1: Few improvements in page layout.
* Makefile.in, /man/Makefile.in, /html/man/tiff2pdf.1.html:
- Added support fpr tiff2pdf manual page.
+ Added support for tiff2pdf manual page.
2003-11-26 Ross Finlayson <libtiff@apexinternetsoftware.com>
@@ -9289,7 +9289,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic
2003-11-26 Andrey Kiselev <dron@ak4719.spb.edu>
* Makefile.in, /tools/{Makefile.in, makefile.vc}:
- Added support fpr tiff2pdf utility.
+ Added support for tiff2pdf utility.
2003-11-25 Ross Finlayson <libtiff@apexinternetsoftware.com>
@@ -9332,7 +9332,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic
2003-11-17 Andrey Kiselev <dron@ak4719.spb.edu>
* contrib/pds/{tif_pdsdirread.c, tif_pdsdirwrite.c}: Use
- TIFFDataWidth() function insted of tiffDataWidth array.
+ TIFFDataWidth() function instead of tiffDataWidth array.
2003-11-16 Andrey Kiselev <dron@ak4719.spb.edu>
@@ -10119,7 +10119,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic
TIFFDataType sizes instead of working with tiffDataWidth array
directly. Should prevent out-of-borders bugs in case of unknown or
broken data types. EstimateStripByteCounts routine modified, so it
- won't work when tags with uknown sizes founded.
+ won't work when tags with unknown sizes founded.
Closes http://bugzilla.remotesensing.org/show_bug.cgi?id=109
2002-03-13 Andrey Kiselev <dron@ak4719.spb.edu>
@@ -10321,7 +10321,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic
* libtiff/tif_getimage.c: relax handling of contig case where
there are extra samples that are supposed to be ignored. This
- should now work for 8bit greyscale or palletted images.
+ should now work for 8bit greyscale or paletted images.
http://bugzilla.remotesensing.org/show_bug.cgi?id=75
@@ -10551,7 +10551,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic
2001-02-16 Frank Warmerdam <warmerdam@pobox.com>
* libtiff/libtiff.def: Brent Roman submitted new version adding
- serveral missing entry points.
+ several missing entry points.
* libtiff/tif_dirinfo.c: don't declare tiffFieldInfo static on VMS.
Some sort of weird VMS thing.
@@ -10961,7 +10961,7 @@ Tue Nov 30 14:41:43 1999 Frank Warmerdam <warmerda@gdal.velocet.ca> *** 3.5
Tue Nov 30 14:15:32 EST 1999 Mike Welles <mike@onshore.com>
- * Added zip creation to relase makefile target
+ * Added zip creation to release makefile target
* Added html for TIFFWriteTile.3t man page.
diff --git a/Makefile.vc b/Makefile.vc
index eeb5d04d..d5da1c52 100644
--- a/Makefile.vc
+++ b/Makefile.vc
@@ -21,7 +21,7 @@
# OF THIS SOFTWARE.
#
# Makefile for MS Visual C and Watcom C compilers.
-# Edit nmake.opt file if you want to ajust building options.
+# Edit nmake.opt file if you want to adjust building options.
#
# To build:
# C:\libtiff> nmake /f makefile.vc
diff --git a/SConstruct b/SConstruct
index ee87fedf..606f366b 100644
--- a/SConstruct
+++ b/SConstruct
@@ -52,7 +52,7 @@ opts.Add(BoolOption('logluv', \
'enable support for LogLuv high dynamic range encoding', \
'yes'))
opts.Add(BoolOption('strip_chopping', \
- 'support for strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of ~8Kb to reduce memory usage)', \
+ 'support for strip chopping (whether or not to convert single-strip uncompressed images to multiple strips of ~8Kb to reduce memory usage)', \
'yes'))
opts.Add(BoolOption('extrasample_as_alpha', \
'the RGBA interface will treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many packages produce RGBA files but don\'t mark the alpha properly', \
diff --git a/archive/tools/bmp2tiff.c b/archive/tools/bmp2tiff.c
index d541e203..704244b7 100644
--- a/archive/tools/bmp2tiff.c
+++ b/archive/tools/bmp2tiff.c
@@ -76,7 +76,7 @@ enum BMPType
* BMPInfoHeader structure. An array of BMPColorEntry structures (also called
* a colour table) follows the bitmap information header structure. The colour
* table is followed by a second array of indexes into the colour table (the
- * actual bitmap data). Data may be comressed, for 4-bpp and 8-bpp used RLE
+ * actual bitmap data). Data may be compressed, for 4-bpp and 8-bpp used RLE
* compression.
*
* +---------------------+
diff --git a/configure.ac b/configure.ac
index a2242330..bcc1eaa9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -456,7 +456,7 @@ dnl Set the floating point format.
dnl FIXME: write appropriate test.
dnl ---------------------------------------------------------------------------
HAVE_IEEEFP=1
-AC_DEFINE_UNQUOTED(HAVE_IEEEFP, $HAVE_IEEEFP, [Define as 0 or 1 according to the floating point format suported by the machine])
+AC_DEFINE_UNQUOTED(HAVE_IEEEFP, $HAVE_IEEEFP, [Define as 0 or 1 according to the floating point format supported by the machine])
dnl ---------------------------------------------------------------------------
dnl Enable run-time paths to libraries usage.
@@ -1106,7 +1106,7 @@ dnl ---------------------------------------------------------------------------
AC_ARG_ENABLE(strip-chopping,
AS_HELP_STRING([--disable-strip-chopping],
- [disable support for strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of specified size to reduce memory usage)]),
+ [disable support for strip chopping (whether or not to convert single-strip uncompressed images to multiple strips of specified size to reduce memory usage)]),
[HAVE_STRIPCHOP=$enableval], [HAVE_STRIPCHOP=yes])
AC_ARG_WITH(default-strip-size,
AS_HELP_STRING([--with-default-strip-size=SIZE],
@@ -1114,7 +1114,7 @@ AC_ARG_WITH(default-strip-size,
if test "$HAVE_STRIPCHOP" = "yes" \
-a "x$with_default_strip_size" != "xno"; then
- AC_DEFINE(STRIPCHOP_DEFAULT,TIFF_STRIPCHOP,[Support strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of specified size to reduce memory usage)])
+ AC_DEFINE(STRIPCHOP_DEFAULT,TIFF_STRIPCHOP,[Support strip chopping (whether or not to convert single-strip uncompressed images to multiple strips of specified size to reduce memory usage)])
if test "x$with_default_strip_size" = "x" \
-o "x$with_default_strip_size" = "xyes"; then
diff --git a/configure.com b/configure.com
index a3064425..bed4e20b 100644
--- a/configure.com
+++ b/configure.com
@@ -46,7 +46,7 @@ $ENDIF
$MMS = F$SEARCH("SYS$SYSTEM:MMS.EXE") .NES. ""
$MMK = F$TYPE(MMK)
$IF (MMS .OR. MMK.NES."") THEN GOTO TEST_LIBRARIES
-$! I cant find any make tool
+$! I cannot find any make tool
$GOTO EXIT
$!
$!
@@ -1126,7 +1126,7 @@ CLEAN :
$!
$!
$!
-$!copiing and patching TIFF_CONF.H, TIF_CONFIG.H
+$!copying and patching TIFF_CONF.H, TIF_CONFIG.H
$!
$CURRENT = F$ENVIRONMENT (""DEFAULT"")
$CURRENT[F$LOCATE("]",CURRENT),9]:=".LIBTIFF]"
@@ -1158,7 +1158,7 @@ $COPY SYS$INPUT 'CURRENT'TIFFCONF.H
/* Compatibility stuff. */
-/* Define as 0 or 1 according to the floating point format suported by the
+/* Define as 0 or 1 according to the floating point format supported by the
machine */
#ifdef __IEEE_FLOAT
@@ -1202,7 +1202,7 @@ $COPY SYS$INPUT 'CURRENT'TIFFCONF.H
/* #undef ZIP_SUPPORT */
/* Support strip chopping (whether or not to convert single-strip uncompressed
- images to mutiple strips of ~8Kb to reduce memory usage) */
+ images to multiple strips of ~8Kb to reduce memory usage) */
#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP
/* Enable SubIFD tag (330) support */
@@ -1244,7 +1244,7 @@ $COPY SYS$INPUT 'CURRENT'TIF_CONFIG.H
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
-/* Define as 0 or 1 according to the floating point format suported by the
+/* Define as 0 or 1 according to the floating point format supported by the
machine */
#ifdef __IEEE_FLOAT
diff --git a/contrib/addtiffo/tif_overview.c b/contrib/addtiffo/tif_overview.c
index 03b35733..591a2aaa 100644
--- a/contrib/addtiffo/tif_overview.c
+++ b/contrib/addtiffo/tif_overview.c
@@ -782,7 +782,7 @@ void TIFFBuildOverviews( TIFF *hTIFF, int nOverviews, int * panOvList,
}
/* -------------------------------------------------------------------- */
-/* Turn off warnings to avoid alot of repeated warnings while */
+/* Turn off warnings to avoid a lot of repeated warnings while */
/* rereading directories. */
/* -------------------------------------------------------------------- */
pfnWarning = TIFFSetWarningHandler( NULL );
@@ -803,7 +803,7 @@ void TIFFBuildOverviews( TIFF *hTIFF, int nOverviews, int * panOvList,
}
/* -------------------------------------------------------------------- */
-/* Capture the pallette if there is one. */
+/* Capture the palette if there is one. */
/* -------------------------------------------------------------------- */
if( TIFFGetField( hTIFF, TIFFTAG_COLORMAP,
&panRedMap, &panGreenMap, &panBlueMap ) )
diff --git a/contrib/pds/tif_pdsdirwrite.c b/contrib/pds/tif_pdsdirwrite.c
index a670bda1..5c161b79 100644
--- a/contrib/pds/tif_pdsdirwrite.c
+++ b/contrib/pds/tif_pdsdirwrite.c
@@ -124,7 +124,7 @@ static int TIFFWriteRational(TIFF*,
the main, standard TIFF directories that does not apply to special
private subdirectories, so such a reimplementation for the sake of
eliminating redundant or duplicate code is probably not possible,
- unless we also pass in a Main flag to indiciate which type of handling
+ unless we also pass in a Main flag to indicate which type of handling
to do, which would be kind of a hack. I've marked those places where I
changed or ripped out code which would have to be re-inserted to
generalize this function. If it can be done in a clean and graceful way,
diff --git a/contrib/tags/README b/contrib/tags/README
index 3220b7b1..d58a5641 100644
--- a/contrib/tags/README
+++ b/contrib/tags/README
@@ -56,7 +56,7 @@ so that multiple clients may be installed.
The TIFFExtendProc method that you define should be used to override
the TIFF file's "vsetfield" and "vgetfield" methods, so that you
can trap your new, private tags, and install their values into
-a private directory structure. For your convienience, a new pointer
+a private directory structure. For your convenience, a new pointer
has also been added to the "TIFF" file structure:
tidata_t tif_clientdir; /* client TIFF directory */
diff --git a/contrib/win_dib/README.Tiffile b/contrib/win_dib/README.Tiffile
index 82c6e5c4..8645f05c 100644
--- a/contrib/win_dib/README.Tiffile
+++ b/contrib/win_dib/README.Tiffile
@@ -2,7 +2,7 @@ Frank,
I attached a file that uses RGBA interface (tif_getimage.c) to read a tiff
file and convert to a DIB. It's advantage is that it is easy to read *any*
-tiff file suported by libtiff and easily convert it to a DIB. The disadvantage
+tiff file supported by libtiff and easily convert it to a DIB. The disadvantage
is that bilevel (B&W) bitmaps (and all other non-rgba images) are also
converted to RGBA, thus taking up 32x as much memory as needed (4 bytes per
pixel, rather than 1 bit). I read tiff files, but don't need to
diff --git a/contrib/win_dib/README.tiff2dib b/contrib/win_dib/README.tiff2dib
index ff70ca1a..75e1254b 100644
--- a/contrib/win_dib/README.tiff2dib
+++ b/contrib/win_dib/README.tiff2dib
@@ -14,7 +14,7 @@ Here is some information that may help someone.
I build the library under Windows 95 as a 32-bit library.
The contribution of Scott Wagner (tif_win32.c) worked fine, but
-the makefile "makefile.msc" was unsable because it was
+the makefile "makefile.msc" was unusable because it was
written for DOS or Windows 3.1 and all the files names
are limited to 8 characters.
@@ -38,7 +38,7 @@ I had to :
I also join the source file "tif2dib.c" that I created,
it contain the function LoadTIFFinDIB that load
a TIFF file and build a memory DIB with it and return the
-HANDLE (HDIB) of the memory bloc containing this DIB.
+HANDLE (HDIB) of the memory block containing this DIB.
Since DIB is the "natural" bitmap format for Windows 3.1, 95 and NT,
this function should be useful for some Windows 95 (or NT) developer.
diff --git a/contrib/win_dib/Tiffile.cpp b/contrib/win_dib/Tiffile.cpp
index 2f7965d6..ca2acd43 100644
--- a/contrib/win_dib/Tiffile.cpp
+++ b/contrib/win_dib/Tiffile.cpp
@@ -329,7 +329,7 @@ DECLAREContigPutFunc(putContig1bitTile)
int wb = WIDTHBYTES(w);
u_char* ucp = (u_char*)cp;
- /* Conver 'w' to bytes from pixels (rounded up) */
+ /* Convert 'w' to bytes from pixels (rounded up) */
w = (w+7)/8;
while (h-- > 0) {
diff --git a/contrib/win_dib/tiff2dib.c b/contrib/win_dib/tiff2dib.c
index 2fa2de69..02c29060 100644
--- a/contrib/win_dib/tiff2dib.c
+++ b/contrib/win_dib/tiff2dib.c
@@ -4,7 +4,7 @@
*
* The function LoadTIFFinDIB in this source file let you load
* a TIFF file and build a memory DIB with it and return the
- * HANDLE (HDIB) of the memory bloc containing the DIB.
+ * HANDLE (HDIB) of the memory block containing the DIB.
*
* Example :
*
@@ -49,7 +49,7 @@ static int checkcmap(int n, uint16* r, uint16* g, uint16* b);
* Description:
*
* This function load a TIFF file and build a memory DIB with it
- * and return the HANDLE (HDIB) of the memory bloc containing
+ * and return the HANDLE (HDIB) of the memory block containing
* the DIB.
*
* 4/12/95 Philippe Tenenhaus 100423.3705@compuserve.com
diff --git a/html/internals.html b/html/internals.html
index 20061ef0..f6516b59 100644
--- a/html/internals.html
+++ b/html/internals.html
@@ -289,7 +289,7 @@ The following defines control general portability:
<TR>
<TD VALIGN=top><TT>HAVE_IEEEFP</TT></TD>
<TD>Define this as 0 or 1 according to the floating point
- format suported by the machine. If your machine does
+ format supported by the machine. If your machine does
not support IEEE floating point then you will need to
add support to tif_machdep.c to convert between the
native format and IEEE format.</TD>
diff --git a/html/libtiff.html b/html/libtiff.html
index cda66b5a..c673b4ff 100644
--- a/html/libtiff.html
+++ b/html/libtiff.html
@@ -296,7 +296,7 @@
the <tt>TIFFGetFieldDefaulted</tt> interface may be used.
</p>
<p>
- The manual pages for the tag get and set routines specifiy the exact data types
+ The manual pages for the tag get and set routines specify the exact data types
and calling conventions required for each tag supported by the library.
</p>
<hr>
diff --git a/html/man/TIFFDataWidth.3tiff.html b/html/man/TIFFDataWidth.3tiff.html
index 9eede060..c8318ded 100644
--- a/html/man/TIFFDataWidth.3tiff.html
+++ b/html/man/TIFFDataWidth.3tiff.html
@@ -75,7 +75,7 @@ TIFF_DOUBLE</i></p>
<td width="8%"></td>
<td width="91%">
<p><i>TIFFDataWidth</i> returns a number of bytes occupied
-by the item of given type. 0 returned when uknown data type
+by the item of given type. 0 returned when unknown data type
supplied.</p>
</td>
</table>
diff --git a/html/man/TIFFReadRGBAImage.3tiff.html b/html/man/TIFFReadRGBAImage.3tiff.html
index f648f099..5bf6527f 100644
--- a/html/man/TIFFReadRGBAImage.3tiff.html
+++ b/html/man/TIFFReadRGBAImage.3tiff.html
@@ -176,7 +176,7 @@ scaling sample values. Palette, grayscale, bilevel,
uncorrected by any colorimetry information present in the
directory.</p>
<!-- INDENTATION -->
-<p>The paramater <i>stopOnError</i> specifies how to act if
+<p>The parameter <i>stopOnError</i> specifies how to act if
an error is encountered while reading the image. If
<i>stopOnError</i> is non-zero, then an error will terminate
the operation; otherwise <i>TIFFReadRGBAImage</i> will
diff --git a/html/v3.4beta007.html b/html/v3.4beta007.html
index c2b51f0a..77c6ac8d 100644
--- a/html/v3.4beta007.html
+++ b/html/v3.4beta007.html
@@ -54,7 +54,7 @@ The following information is located here:
<LI>Niles Ritter's client tag extension hooks were added
<LI>a new routine <TT>TIFFCurrentDirOffset</TT> was added for
applications that want to find out the file offset of a TIFF directory
-<LI>the calculation of the number of strips in an image was corected
+<LI>the calculation of the number of strips in an image was corrected
for images with certain esoteric configurations
<LI>a potential memory leak (very unlikely) was plugged
<LI>the <TT>TIFFReadRGBAImage</TT> support was completely rewritten
diff --git a/html/v3.4beta016.html b/html/v3.4beta016.html
index 11035384..e959af8e 100644
--- a/html/v3.4beta016.html
+++ b/html/v3.4beta016.html
@@ -55,7 +55,7 @@ The following information is located here:
<LI>support was added for registering new codecs external to the library
and for overriding the codecs that are builtin to the library
<LI>emulation support for the old <TT>DataType</TT> tag was improved
-<LI>suppport was added for the <TT>SMinSampleValue</TT>
+<LI>support was added for the <TT>SMinSampleValue</TT>
and <TT>SMaxSampleValue</TT> tags
<LI>the library no longer ignores <TT>TileWidth</TT> and <TT>TileLength</TT>
tags whose values are not a multiple of 16 (per the spec); this
diff --git a/html/v3.4beta028.html b/html/v3.4beta028.html
index 5ae0e490..1d54afe1 100644
--- a/html/v3.4beta028.html
+++ b/html/v3.4beta028.html
@@ -84,7 +84,7 @@ The following information is located here:
order, and ``H'' for the bit order of the native CPU)
<LI>the byte order of image and tag data written to newly-created files
can now be controlled on a per-file basis through a mode parameter
- supplied when openening a file (``b'' to force Big-Endian byte order
+ supplied when opening a file (``b'' to force Big-Endian byte order
and ``l'' to force Little-Endian byte order)
<LI>the use memory-mapped files for images opened read-only can now
be controlled on a per-file basis through a mode parameter supplied
diff --git a/html/v3.5.7.html b/html/v3.5.7.html
index a58b7e5a..5ae2d26c 100644
--- a/html/v3.5.7.html
+++ b/html/v3.5.7.html
@@ -44,7 +44,7 @@ The following information is located here:
<UL>
<li> libtiff/libtiff.def: Brent Roman submitted new version adding
-serveral missing entry points. Also add a few other entry points
+several missing entry points. Also add a few other entry points
later.
<li> configure, Makefile.in, etc: added support for OPTIMIZER being
@@ -152,7 +152,7 @@ later.
<li> libtiff/tif_getimage.c: relax handling of contig case where
there are extra samples that are supposed to be ignored as per bug 75. This
-should now work for 8bit greyscale or palletted images.
+should now work for 8bit greyscale or paletted images.
<li> libtiff/tif_packbits.c: fixed memory overrun error as per bug 77.
diff --git a/html/v3.6.0.html b/html/v3.6.0.html
index 1a3ba4a9..57613867 100644
--- a/html/v3.6.0.html
+++ b/html/v3.6.0.html
@@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this
timeframe, or it was not considered important enough to be mentioned.
The following information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
@@ -108,7 +108,7 @@ with externally defined tags is the primary reason for the shift to the
<UL>
<li> configure, config.site: Fix for large files (>2GiB) support. New
-option in the config.site: LARGEFILE="yes". Should be enougth for the large
+option in the config.site: LARGEFILE="yes". Should be enough for the large
files I/O.
<li> configure: Set -DPIXARLOG_SUPPORT option along with -DZIP_SUPPORT.
diff --git a/html/v3.6.1.html b/html/v3.6.1.html
index 6a357f4c..e7036c0f 100644
--- a/html/v3.6.1.html
+++ b/html/v3.6.1.html
@@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this
timeframe, or it was not considered important enough to be mentioned.
The following information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
@@ -125,7 +125,7 @@ interface. YCbCr to RGB conversion code also moved there and now has
<a href="./man/TIFFcolor.3t.html">publicly available interface</a>. These
routines currently used in TIFFRGBAImage interface only and not supported in
other libtiff tools yet. So if you want, for example, to convert CIE Lab image
-into PostScript file you should do it in two steps: chnge colorspace to RGB
+into PostScript file you should do it in two steps: change colorspace to RGB
using <a href="./man/tiff2rgba.1.html">tiff2rgba</a> utility abd then process
it with the <a href="./man/tiff2ps.1.html">tiff2ps</a>.
@@ -176,7 +176,7 @@ lines.
<UL>
<li> contrib/pds/{tif_pdsdirread.c, tif_pdsdirwrite.c}: Use TIFFDataWidth()
-function insted of tiffDataWidth array.
+function instead of tiffDataWidth array.
</UL>
diff --git a/html/v3.7.0.html b/html/v3.7.0.html
index 9c0819a4..c08fb3b6 100644
--- a/html/v3.7.0.html
+++ b/html/v3.7.0.html
@@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this
timeframe, or it was not considered important enough to be mentioned.
The following information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
diff --git a/html/v3.7.0alpha.html b/html/v3.7.0alpha.html
index 39b63238..70b11177 100644
--- a/html/v3.7.0alpha.html
+++ b/html/v3.7.0alpha.html
@@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this
timeframe, or it was not considered important enough to be mentioned.
The following information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
diff --git a/html/v3.7.0beta.html b/html/v3.7.0beta.html
index f646480f..8ed682ca 100644
--- a/html/v3.7.0beta.html
+++ b/html/v3.7.0beta.html
@@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this
timeframe, or it was not considered important enough to be mentioned.
The following information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
diff --git a/html/v3.7.0beta2.html b/html/v3.7.0beta2.html
index 41ba6c3a..0b0b9a82 100644
--- a/html/v3.7.0beta2.html
+++ b/html/v3.7.0beta2.html
@@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this
timeframe, or it was not considered important enough to be mentioned.
The following information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
diff --git a/html/v3.7.1.html b/html/v3.7.1.html
index 164b4059..66263cd5 100644
--- a/html/v3.7.1.html
+++ b/html/v3.7.1.html
@@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this
timeframe, or it was not considered important enough to be mentioned.
The following information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
diff --git a/html/v3.7.2.html b/html/v3.7.2.html
index d396021e..ac1ae85d 100644
--- a/html/v3.7.2.html
+++ b/html/v3.7.2.html
@@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this
timeframe, or it was not considered important enough to be mentioned.
The following information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
diff --git a/html/v3.7.3.html b/html/v3.7.3.html
index 54978c8f..bc1dc26d 100644
--- a/html/v3.7.3.html
+++ b/html/v3.7.3.html
@@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this
timeframe, or it was not considered important enough to be mentioned.
The following information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
diff --git a/html/v3.7.4.html b/html/v3.7.4.html
index eeb0f3ca..a811a173 100644
--- a/html/v3.7.4.html
+++ b/html/v3.7.4.html
@@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this
timeframe, or it was not considered important enough to be mentioned.
The following information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
diff --git a/html/v3.8.0.html b/html/v3.8.0.html
index 81a8b0c6..be1529ba 100644
--- a/html/v3.8.0.html
+++ b/html/v3.8.0.html
@@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this
timeframe, or it was not considered important enough to be mentioned.
The following information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
@@ -110,7 +110,7 @@ The following information is located here:
<a href="http://bugzilla.remotesensing.org/show_bug.cgi?id=1003">
http://bugzilla.remotesensing.org/show_bug.cgi?id=1003</a>
- <li> tif_dirinfo.c: Correctly yse bsearch() and lfind()
+ <li> tif_dirinfo.c: Correctly use bsearch() and lfind()
functions as per bug
<a href="http://bugzilla.remotesensing.org/show_bug.cgi?id=1008">
http://bugzilla.remotesensing.org/show_bug.cgi?id=1008</a>
@@ -170,7 +170,7 @@ The following information is located here:
<a href="http://bugzilla.remotesensing.org/show_bug.cgi?id=965">
http://bugzilla.remotesensing.org/show_bug.cgi?id=965</a>
- <li> tiffsplit.c: Copy fax related fields over splitted parts
+ <li> tiffsplit.c: Copy fax related fields over split parts
as per bug
<a href="http://bugzilla.remotesensing.org/show_bug.cgi?id=983">
http://bugzilla.remotesensing.org/show_bug.cgi?id=983</a>
diff --git a/html/v3.8.1.html b/html/v3.8.1.html
index 0fe7d9c0..d53bb1fb 100644
--- a/html/v3.8.1.html
+++ b/html/v3.8.1.html
@@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this
timeframe, or it was not considered important enough to be mentioned.
The following information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
diff --git a/html/v3.8.2.html b/html/v3.8.2.html
index 41bb2e55..7a33181b 100644
--- a/html/v3.8.2.html
+++ b/html/v3.8.2.html
@@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this
timeframe, or it was not considered important enough to be mentioned.
The following information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
diff --git a/html/v3.9.0.html b/html/v3.9.0.html
index 540e7cf2..35df1c23 100644
--- a/html/v3.9.0.html
+++ b/html/v3.9.0.html
@@ -32,7 +32,7 @@ find something listed here, then it was not done in this timeframe, or
it was not considered important enough to be mentioned. The following
information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
diff --git a/html/v3.9.0beta.html b/html/v3.9.0beta.html
index 56f32ed3..ef6214ad 100644
--- a/html/v3.9.0beta.html
+++ b/html/v3.9.0beta.html
@@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this
timeframe, or it was not considered important enough to be mentioned.
The following information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
@@ -74,7 +74,7 @@ The following information is located here:
tif_config.vc.h for easier identification by folks using an IDE.
<li> configure, configure.ac: OJPEG support enabled by default (i.e.,
- whe the conformant JPEG support enabled).
+ when conformant JPEG support is enabled).
<li> README.vms, Makefile.am, configure.com, libtiff/{Makefile.am,
tif_config.h-vms, tif_stream.cxx, tif_vms.c, tiffconf.h-vms}:
diff --git a/html/v3.9.1.html b/html/v3.9.1.html
index 1f369a83..2f5a7afa 100644
--- a/html/v3.9.1.html
+++ b/html/v3.9.1.html
@@ -32,7 +32,7 @@ find something listed here, then it was not done in this timeframe, or
it was not considered important enough to be mentioned. The following
information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
diff --git a/html/v3.9.2.html b/html/v3.9.2.html
index a190a301..8bd9dc85 100644
--- a/html/v3.9.2.html
+++ b/html/v3.9.2.html
@@ -32,7 +32,7 @@ find something listed here, then it was not done in this timeframe, or
it was not considered important enough to be mentioned. The following
information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
diff --git a/html/v3.9.3.html b/html/v3.9.3.html
index 52a9f087..87657071 100644
--- a/html/v3.9.3.html
+++ b/html/v3.9.3.html
@@ -32,7 +32,7 @@ find something listed here, then it was not done in this timeframe, or
it was not considered important enough to be mentioned. The following
information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
diff --git a/html/v3.9.4.html b/html/v3.9.4.html
index 3f5ef5c7..b201366e 100644
--- a/html/v3.9.4.html
+++ b/html/v3.9.4.html
@@ -32,7 +32,7 @@ find something listed here, then it was not done in this timeframe, or
it was not considered important enough to be mentioned. The following
information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
diff --git a/html/v3.9.5.html b/html/v3.9.5.html
index 666220f3..6cae7d9c 100644
--- a/html/v3.9.5.html
+++ b/html/v3.9.5.html
@@ -32,7 +32,7 @@ find something listed here, then it was not done in this timeframe, or
it was not considered important enough to be mentioned. The following
information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
diff --git a/html/v4.0.0.html b/html/v4.0.0.html
index a7e9bb63..d9b4c2bd 100644
--- a/html/v4.0.0.html
+++ b/html/v4.0.0.html
@@ -33,7 +33,7 @@ it was not considered important enough to be mentioned. Please consult
the ChangeLog file in the source package for full change details. The
following information is located here:
<UL>
-<LI><A HREF="#hightlights">Major Changes</A>
+<LI><A HREF="#highlights">Major Changes</A>
<LI><A HREF="#configure">Changes in the software configuration</A>
<LI><A HREF="#libtiff">Changes in libtiff</A>
<LI><A HREF="#tools">Changes in the tools</A>
diff --git a/html/v4.0.4beta.html b/html/v4.0.4beta.html
index e9e70a55..66e451a8 100644
--- a/html/v4.0.4beta.html
+++ b/html/v4.0.4beta.html
@@ -112,7 +112,7 @@ information is located here:
putcontig8bitYCbCr21tile cases.
<li> in TIFFDefaultDirectory(), reset any already existing
- extented tags installed by user code through the extender mechaninm before
+ extended tags installed by user code through the extender mechaninm before
calling the extender callback (GDAL #5054)
<li> Fix warnings about unused parameters.
diff --git a/html/v4.0.7.html b/html/v4.0.7.html
index 4f92c129..dab75df8 100644
--- a/html/v4.0.7.html
+++ b/html/v4.0.7.html
@@ -252,7 +252,7 @@ information is located here:
tif_encodestrip() as documented
<LI> libtiff/tif_dumpmode.c: DumpModeEncode() should return 0 in
- case of failure so that the above mentionned functions detect
+ case of failure so that the above mentioned functions detect
the error.
<LI> libtiff/*.c: fix MSVC warnings related to cast shortening and
diff --git a/html/v4.0.8.html b/html/v4.0.8.html
index bd3f751c..456f2bdb 100644
--- a/html/v4.0.8.html
+++ b/html/v4.0.8.html
@@ -98,7 +98,7 @@ information is located here:
makes it unnecessary.
<LI> libtiff/tif_dirread.c: modify ChopUpSingleUncompressedStrip()
- to instanciate compute ntrips as
+ to instantiate compute ntrips as
TIFFhowmany_32(td->td_imagelength, rowsperstrip), instead of a
logic based on the total size of data. Which is faulty is the
total size of data is not sufficient to fill the whole image,
diff --git a/html/v4.0.9.html b/html/v4.0.9.html
index 19b370a4..6ab33510 100644
--- a/html/v4.0.9.html
+++ b/html/v4.0.9.html
@@ -170,7 +170,7 @@ information is located here:
scans and not interleavedin a single one, needs to allocate memory (or
backing store) for the whole strip/tile.
See http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf
- This limitation may be overriden by setting the
+ This limitation may be overridden by setting the
LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC environment variable, or recompiling
libtiff with a custom value of TIFF_LIBJPEG_LARGEST_MEM_ALLOC macro.
<LI> libtiff/tif_jbig.c: fix memory leak in error code path of JBIGDecode()
diff --git a/libtiff/tif_config.h-vms b/libtiff/tif_config.h-vms
index d653bd82..ede11a59 100644
--- a/libtiff/tif_config.h-vms
+++ b/libtiff/tif_config.h-vms
@@ -4,7 +4,7 @@
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
-/* Define as 0 or 1 according to the floating point format suported by the
+/* Define as 0 or 1 according to the floating point format supported by the
machine */
#define HAVE_IEEEFP 1
diff --git a/libtiff/tif_config.vc.h b/libtiff/tif_config.vc.h
index 939594f8..66cb20bc 100644
--- a/libtiff/tif_config.vc.h
+++ b/libtiff/tif_config.vc.h
@@ -7,7 +7,7 @@
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
-/* Define as 0 or 1 according to the floating point format suported by the
+/* Define as 0 or 1 according to the floating point format supported by the
machine */
#define HAVE_IEEEFP 1
diff --git a/libtiff/tif_config.wince.h b/libtiff/tif_config.wince.h
index e85e2e62..da09ba18 100644
--- a/libtiff/tif_config.wince.h
+++ b/libtiff/tif_config.wince.h
@@ -11,7 +11,7 @@
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
-/* Define as 0 or 1 according to the floating point format suported by the
+/* Define as 0 or 1 according to the floating point format supported by the
machine */
#define HAVE_IEEEFP 1
diff --git a/libtiff/tif_dir.c b/libtiff/tif_dir.c
index 347b7115..b578c8cf 100644
--- a/libtiff/tif_dir.c
+++ b/libtiff/tif_dir.c
@@ -1381,7 +1381,7 @@ TIFFCreateCustomDirectory(TIFF* tif, const TIFFFieldArray* infoarray)
/*
* Reset the field definitions to match the application provided list.
- * Hopefully TIFFDefaultDirectory() won't have done anything irreversable
+ * Hopefully TIFFDefaultDirectory() won't have done anything irreversible
* based on it's assumption this is an image directory.
*/
_TIFFSetupFields(tif, infoarray);
diff --git a/libtiff/tif_vms.c b/libtiff/tif_vms.c
index cf4e9f34..79e4c5c8 100644
--- a/libtiff/tif_vms.c
+++ b/libtiff/tif_vms.c
@@ -350,7 +350,7 @@ asm("_$$PsectAttributes_NOSHR$$_TIFFerrorHandler")
#if !HAVE_IEEEFP
-/* IEEE floting point handling */
+/* IEEE floating point handling */
typedef struct ieeedouble {
unsigned long mant2; /* fix NDR: full 8-byte swap */
diff --git a/libtiff/tiffconf.h-vms b/libtiff/tiffconf.h-vms
index 72b03390..ab31c0b5 100644
--- a/libtiff/tiffconf.h-vms
+++ b/libtiff/tiffconf.h-vms
@@ -15,7 +15,7 @@
/* Compatibility stuff. */
-/* Define as 0 or 1 according to the floating point format suported by the
+/* Define as 0 or 1 according to the floating point format supported by the
machine */
#define HAVE_IEEEFP 1
@@ -60,7 +60,7 @@
/* #undef ZIP_SUPPORT */
/* Support strip chopping (whether or not to convert single-strip uncompressed
- images to mutiple strips of ~8Kb to reduce memory usage) */
+ images to multiple strips of ~8Kb to reduce memory usage) */
#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP
/* Enable SubIFD tag (330) support */
diff --git a/libtiff/tiffconf.h.cmake.in b/libtiff/tiffconf.h.cmake.in
index 9b4b0328..dcaca7f5 100644
--- a/libtiff/tiffconf.h.cmake.in
+++ b/libtiff/tiffconf.h.cmake.in
@@ -42,7 +42,7 @@
/* Compatibility stuff. */
-/* Define as 0 or 1 according to the floating point format suported by the
+/* Define as 0 or 1 according to the floating point format supported by the
machine */
#cmakedefine HAVE_IEEEFP 1
@@ -91,7 +91,7 @@
#cmakedefine LIBDEFLATE_SUPPORT 1
/* Support strip chopping (whether or not to convert single-strip uncompressed
- images to mutiple strips of ~8Kb to reduce memory usage) */
+ images to multiple strips of ~8Kb to reduce memory usage) */
#cmakedefine STRIPCHOP_DEFAULT 1
/* Enable SubIFD tag (330) support */
diff --git a/libtiff/tiffconf.h.in b/libtiff/tiffconf.h.in
index 9bd6a2de..f15bff0e 100644
--- a/libtiff/tiffconf.h.in
+++ b/libtiff/tiffconf.h.in
@@ -39,7 +39,7 @@
/* Compatibility stuff. */
-/* Define as 0 or 1 according to the floating point format suported by the
+/* Define as 0 or 1 according to the floating point format supported by the
machine */
#undef HAVE_IEEEFP
@@ -88,7 +88,7 @@
#undef LIBDEFLATE_SUPPORT
/* Support strip chopping (whether or not to convert single-strip uncompressed
- images to mutiple strips of ~8Kb to reduce memory usage) */
+ images to multiple strips of ~8Kb to reduce memory usage) */
#undef STRIPCHOP_DEFAULT
/* Enable SubIFD tag (330) support */
diff --git a/libtiff/tiffconf.vc.h b/libtiff/tiffconf.vc.h
index fb37a755..2078cdbd 100644
--- a/libtiff/tiffconf.vc.h
+++ b/libtiff/tiffconf.vc.h
@@ -66,7 +66,7 @@
/* Compatibility stuff. */
-/* Define as 0 or 1 according to the floating point format suported by the
+/* Define as 0 or 1 according to the floating point format supported by the
machine */
#define HAVE_IEEEFP 1
@@ -112,7 +112,7 @@
/* #undef ZIP_SUPPORT */
/* Support strip chopping (whether or not to convert single-strip uncompressed
- images to mutiple strips of ~8Kb to reduce memory usage) */
+ images to multiple strips of ~8Kb to reduce memory usage) */
#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP
/* Enable SubIFD tag (330) support */
diff --git a/libtiff/tiffconf.wince.h b/libtiff/tiffconf.wince.h
index 013b0960..05fd0564 100644
--- a/libtiff/tiffconf.wince.h
+++ b/libtiff/tiffconf.wince.h
@@ -30,7 +30,7 @@
/* Compatibility stuff. */
-/* Define as 0 or 1 according to the floating point format suported by the
+/* Define as 0 or 1 according to the floating point format supported by the
machine */
#define HAVE_IEEEFP 1
@@ -73,7 +73,7 @@
/* #undef ZIP_SUPPORT */
/* Support strip chopping (whether or not to convert single-strip uncompressed
- images to mutiple strips of ~8Kb to reduce memory usage) */
+ images to multiple strips of ~8Kb to reduce memory usage) */
#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP
/* Enable SubIFD tag (330) support */
diff --git a/man/TIFFDataWidth.3tiff b/man/TIFFDataWidth.3tiff
index efcd39d7..d69cd115 100644
--- a/man/TIFFDataWidth.3tiff
+++ b/man/TIFFDataWidth.3tiff
@@ -65,7 +65,7 @@ Currently following data types are supported:
.br
.IR TIFFDataWidth
returns a number of bytes occupied by the item of given type. 0 returned when
-uknown data type supplied.
+unknown data type supplied.
.SH "SEE ALSO"
.BR libtiff (3TIFF),
.PP
diff --git a/man/TIFFReadRGBAImage.3tiff b/man/TIFFReadRGBAImage.3tiff
index 920fc370..6cdf4b8b 100644
--- a/man/TIFFReadRGBAImage.3tiff
+++ b/man/TIFFReadRGBAImage.3tiff
@@ -109,7 +109,7 @@ transparently.
Raster pixels are returned uncorrected by any colorimetry information
present in the directory.
.PP
-The paramater
+The parameter
.I stopOnError
specifies how to act if an error is encountered while reading
the image.
diff --git a/man/tiffcrop.1 b/man/tiffcrop.1
index d7a4c4d7..d133f652 100644
--- a/man/tiffcrop.1
+++ b/man/tiffcrop.1
@@ -133,7 +133,7 @@ or
may be used to specify all odd or even numbered images counting from one.
Note that internally, TIFF images are numbered from zero rather than one
but since this convention is not obvious to most users, tiffcrop used 1
-to specifiy the first image in a multipage file. The word
+to specify the first image in a multipage file. The word
.B last
may be used in place of a number in the sequence to indicate the
final image in the file without knowing how many images there are.
@@ -144,8 +144,8 @@ to process the 1st, 5th through 7th, and final image in the file.
.TP
.B \-E top|bottom|left|right
Specify the top, bottom, left, or right edge as the reference from
-which to calcuate the width and length of crop regions or sequence
-of postions for zones. When used with the \-e option for exporting
+which to calculate the width and length of crop regions or sequence
+of positions for zones. When used with the \-e option for exporting
zones or regions, the reference edge determines how composite images
are arranged. Using \-E left or right causes successive zones or
regions to be merged horizontally whereas using \-E top or bottom
@@ -549,11 +549,11 @@ additional ones may be added in the future. It will handle tiled images with
bit depths that are not a multiple of eight that tiffcp may refuse to read.
.PP
.I Tiffcrop
-was designed to handle large files containing many moderate sized images
-with memory usage that is independent of the number of images in the file.
+was designed to handle large files containing many moderate sized images
+with memory usage that is independent of the number of images in the file.
In order to support compression modes that are not based on individual
scanlines, e.g. JPEG, it now reads images by strip or tile rather than by
-indvidual scanlines. In addition to the memory required by the input and
+individual scanlines. In addition to the memory required by the input and
output buffers associated with
.I LibTIFF
one or more buffers at least as large as the largest image to be read are
diff --git a/nmake.opt b/nmake.opt
index d9bf15f1..c07203ed 100644
--- a/nmake.opt
+++ b/nmake.opt
@@ -84,7 +84,7 @@ LOGLUV_SUPPORT = 1
#
# Comment out the following lines to disable strip chopping
-# (whether or not to convert single-strip uncompressed images to mutiple
+# (whether or not to convert single-strip uncompressed images to multiple
# strips of specified size to reduce memory usage). Default strip size
# is 8192 bytes, it can be configured via the STRIP_SIZE_DEFAULT parameter
#
diff --git a/test/custom_dir_EXIF_231.c b/test/custom_dir_EXIF_231.c
index 854b19a9..627edf84 100644
--- a/test/custom_dir_EXIF_231.c
+++ b/test/custom_dir_EXIF_231.c
@@ -1,1398 +1,1397 @@
-
-/*
- * Copyright (c) 2012, Frank Warmerdam <warmerdam@pobox.com>
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the names of
- * Sam Leffler and Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Sam Leffler and Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-/*
- * TIFF Library
- *
- * -- Module copied from custom_dir.c --
- *=========== Purpose ===================================================================================
- * Extended and amended version for testing of EXIF 2.32, GPS and handling of custom fields.
- * EXIF 2.32 and GPS are defined in amended files tif_dirinfo.c, tif_dirread.c, tiff.h, tiffio.h, tif_dir.h, tif_dir.c
- *
- *-- ATTENTION: After the upgrade with Rational2Double, the GPSTAG values are defined as double precision
- * and need to be written and also read in double precision!
- * In order to maintain this code for both cases, it is checked above if the TiffLibrary is
- * compiled with the new interface with Rational2Double or still uses the old definitions,
- * by setting blnIsRational2Double above.
- *
- */
-
-
-/*------------
- * This version writes the GPS and EXIF tags correctly, without additonal main-IFD and parameters!
- * In contrary, custom_dir.c does write additional main-IFD and parameters to file.
- -------------*/
-
-
-#define FOR_AUTO_TESTING
-#ifdef FOR_AUTO_TESTING
-/* Only for automake and CMake infrastructure the test should:
- a.) delete any written testfiles when test passed (otherwise autotest will fail)
- b.) goto failure, if any failure is detected, which is not necessary when test is initiated manually for debugging
-*/
-#define GOTOFAILURE goto failure;
-#define GOTOFAILURE_GPS goto failure;
-#define GOTOFAILURE_ALL_EXIF goto failure;
-#else
-#define GOTOFAILURE
-#define GOTOFAILURE_GPS
-#define GOTOFAILURE_ALL_EXIF
-#endif
-
-
-#ifdef _MSC_VER
-#pragma warning( disable : 4101)
-#endif
-
-#include "tif_config.h"
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include <errno.h>
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#include "tiffio.h"
-#include "tiffiop.h"
-#include "tif_dir.h"
-#include "tifftest.h"
-
-
-
-int write_test_tiff(TIFF *tif, const char *filenameRead);
-
-static const char filename[] = "custom_dir_EXIF_231.tif";
-static const char filenameBigTiff[] = "custom_dir_EXIF_231_Big.tif";
-
-#define SPP 3 /* Samples per pixel */
-const uint16 width = 1;
-const uint16 length = 1;
-const uint16 bps = 8;
-const uint16 photometric = PHOTOMETRIC_RGB;
-const uint16 rows_per_strip = 1;
-const uint16 planarconfig = PLANARCONFIG_CONTIG;
-
-
-int
-main()
-{
- TIFF *tif;
- int ret, ret1, ret2;
-
- fprintf(stderr, "==== Test automatically if all EXIF and GPS tags are written/read correctly. ====\n");
- /* --- Test with Classic-TIFF ---*/
- /* delete file, if exists */
- ret = unlink(filename);
- if (ret != 0 && errno != ENOENT) {
- fprintf(stderr, "Can't delete test TIFF file %s.\n", filename);
- }
-
- /* We write the main directory as a simple image. */
- tif = TIFFOpen(filename, "w+");
- if (!tif) {
- fprintf(stderr, "Can't create test TIFF file %s.\n", filename);
- return 1;
- }
- fprintf(stderr, "-------- Test with ClassicTIFF started ----------\n");
- ret1 = write_test_tiff(tif, filename);
-
- if (ret1 > 0) return(ret1);
-
- /*--- Test with BIG-TIFF ---*/
- /* delete file, if exists */
- ret = unlink(filenameBigTiff);
- if (ret != 0 && errno != ENOENT) {
- fprintf(stderr, "Can't delete test TIFF file %s.\n", filenameBigTiff);
- }
-
- tif = TIFFOpen(filenameBigTiff, "w8");
- if (!tif) {
- fprintf(stderr, "Can't create test TIFF file %s.\n", filenameBigTiff);
- return 1;
- }
- fprintf(stderr, "\n\n-------- Test with BigTIFF started ----------\n");
- ret2 = write_test_tiff(tif, filenameBigTiff);
-
- if (ret2 > 0) return(ret2 + 10); else return(ret2);
-
-} /* main() */
-
-
-
-
-
-
-
-int
-write_test_tiff(TIFF *tif, const char *filenameRead)
-{
- unsigned char buf[SPP] = { 0, 127, 255 };
- uint64 dir_offset = 0;
- uint64 dir_offset_GPS = 0, dir_offset_EXIF = 0;
- uint64 read_dir_offset = 0;
- /*-- Additional variables --*/
- int retCode, retCode2;
- unsigned char exifVersion[4] = {'0','2','3','1'}; /* EXIF 2.31 version is 4 characters of a string! */
- unsigned char gpsVersion[4] = {2,2,0,1}; /* GPS Version is 4 numbers! */
- unsigned char *pGpsVersion;
- float auxFloat = 0.0f;
- double auxDouble = 0.0;
- char auxChar = 0;
- uint32 auxUint32 = 0;
- short auxShort=0;
- long auxLong = 0;
- void *pVoid;
- int blnIsRational2Double;
-
- int i, j;
- long nTags;
-
- const TIFFFieldArray* tFieldArray;
- unsigned long tTag;
- TIFFDataType tType;
- short tWriteCount;
- TIFFSetGetFieldType tSetFieldType;
- char *tFieldName;
- const TIFFField *fip;
-
- char blnFillGPSManually = 1;
-
-#define STRSIZE 1000
-#define N_SIZE 120
-#define VARIABLE_ARRAY_SIZE 6
-
- /* -- Test data for writing -- */
- char auxCharArrayW[N_SIZE];
- short auxShortArrayW[N_SIZE];
- long auxLongArrayW[N_SIZE];
- float auxFloatArrayW[N_SIZE];
- double auxDoubleArrayW[N_SIZE];
- char auxTextArrayW[N_SIZE][STRSIZE];
- double auxDoubleArrayGPS1[3] = {1.0/7.0, 61.23456789012345, 62.0};
- double auxDoubleArrayGPS2[3] = {1.0/19.0, 88.34434, 15.12345678901234567890};
- double auxDoubleArrayGPSTime[3] = {22.0, 17.0, 15.3456789};
- double auxDoubleGPSAltitude = 3456.0;
- double auxDoubleGPSDirection = 63.7;
- float auxFloatArrayN1[3] = { 1.0f / 7.0f, 61.23456789012345f, 62.3f };
- float auxFloatArrayN2[3] = { -1.0f / 7.0f, -61.23456789012345f, -62.3f };
-
- /* -- Variables for reading -- */
- uint16 count16 = 0;
- union {
- long Long;
- short Short1;
- short Short2[2];
- char Char[4];
- } unionLong;
- union {
- double dbl;
- float flt1;
- float flt2;
- } auxDblUnion;
- void *pVoidArray;
- char *pAscii;
- char auxCharArray[2*STRSIZE];
- short auxShortArray[2*N_SIZE];
- long auxLongArray[2*N_SIZE];
- float auxFloatArray[2*N_SIZE];
- double auxDoubleArray[2*N_SIZE];
- double dblDiff, dblDiffLimit;
-#define RATIONAL_EPS (1.0/30000.0) /* reduced difference of rational values, approx 3.3e-5 */
-
- /*-- Fill test data arrays for writing ----------- */
- for (i=0; i<N_SIZE; i++) {
- sprintf(auxTextArrayW[i],"N%d-String-%d_tttttttttttttttttttttttttttttx", i, i);
- }
- for (i=0; i<N_SIZE; i++) {
- auxCharArrayW[i] = (char)(i+1);
- }
- for (i=0; i<N_SIZE; i++) {
- auxShortArrayW[i] = (short)(i+1)*7;
- }
- for (i=0; i<N_SIZE; i++) {
- auxLongArrayW[i] = (i+1)*133;
- }
- for (i=0; i<N_SIZE; i++) {
- auxFloatArrayW[i] = (float)((i+1)*133)/3.3f;
- }
- for (i=0; i<N_SIZE; i++) {
- auxDoubleArrayW[i] = (double)((i+1)*3689)/4.5697;
- }
-
- /*-- Setup standard tags of a simple tiff file --*/
- if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) {
- fprintf (stderr, "Can't set ImageWidth tag.\n");
- goto failure;
- }
- if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) {
- fprintf (stderr, "Can't set ImageLength tag.\n");
- goto failure;
- }
- if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps)) {
- fprintf (stderr, "Can't set BitsPerSample tag.\n");
- goto failure;
- }
- if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP)) {
- fprintf (stderr, "Can't set SamplesPerPixel tag.\n");
- goto failure;
- }
- if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) {
- fprintf (stderr, "Can't set SamplesPerPixel tag.\n");
- goto failure;
- }
- if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, planarconfig)) {
- fprintf (stderr, "Can't set PlanarConfiguration tag.\n");
- goto failure;
- }
- if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric)) {
- fprintf (stderr, "Can't set PhotometricInterpretation tag.\n");
- goto failure;
- }
-
-#define ADDITIONAL_TAGS
-#ifdef ADDITIONAL_TAGS
- /*-- Additional tags to check Rational standard tags, which are also defined as FIELD_CUSTOM */
-
- /*- TIFFTAG_INKSET is a SHORT parameter (TIFF_SHORT, TIFF_SETGET_UINT16) with field_bit=FIELD_CUSTOM !! -*/
- if (!TIFFSetField(tif, TIFFTAG_INKSET, 34)) {
- fprintf(stderr, "Can't set TIFFTAG_INKSET tag.\n");
- goto failure;
- }
-
- /*- TIFFTAG_PIXAR_FOVCOT is a FLOAT parameter ( TIFF_FLOAT, TIFF_SETGET_FLOAT) with field_bit=FIELD_CUSTOM !! -*/
- /* - can be written with Double but has to be read with float parameter */
-#define PIXAR_FOVCOT_VAL 5.123456789123456789
- auxFloat = (float)PIXAR_FOVCOT_VAL;
- auxDouble = (double)PIXAR_FOVCOT_VAL;
- if (!TIFFSetField(tif, TIFFTAG_PIXAR_FOVCOT, auxDouble)) {
- fprintf(stderr, "Can't set TIFFTAG_PIXAR_FOVCOT tag.\n");
- goto failure;
- }
- /*- TIFFTAG_STONITS is a DOUBLE parameter (TIFF_DOUBLE, TIFF_SETGET_DOUBLE) with field_bit=FIELD_CUSTOM!
- * Only TIFFTAG_STONITS is a TIFF_DOUBLE, which has to be read as DOUBLE!!
- */
-#define STONITS_VAL 6.123456789123456789
- auxDouble = STONITS_VAL;
- auxFloat = (float)auxDouble;
- if (!TIFFSetField(tif, TIFFTAG_STONITS, auxDouble)) {
- fprintf(stderr, "Can't set TIFFTAG_STONITS tag.\n");
- goto failure;
- }
-
- /*- TIFFTAG_YCBCRPOSITIONING is a SHORT parameter */
- auxLong = auxShort = 5;
- if (!TIFFSetField(tif, TIFFTAG_YCBCRPOSITIONING, auxLong )) {
- fprintf (stderr, "Can't set TIFFTAG_YCBCRPOSITIONING tag.\n");
- goto failure;
- }
-
- /* - TIFFTAG_BESTQUALITYSCALE is a Rational parameter, FIELD_CUSTOM and TIFF_SETGET_DOUBLE */
- /* With Rational2Double upgrade tag is redefined to TIFF_SETGET_FLOAT, but can be still written with double. */
-#define BESTQUALITYSCALE_VAL 15.3
- auxDouble = BESTQUALITYSCALE_VAL;
- if (!TIFFSetField(tif, TIFFTAG_BESTQUALITYSCALE, auxDouble )) {
- fprintf (stderr, "Can't set TIFFTAG_BESTQUALITYSCALE tag.\n");
- goto failure;
- }
-
- /* - TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT */
- if (!TIFFSetField(tif, TIFFTAG_BASELINENOISE, auxDouble)) {
- fprintf(stderr, "Can't set TIFFTAG_BASELINENOISE tag.\n");
- goto failure;
- }
-
-
- /*--- For static or variable ARRAYs the case is different ---*/
-/*- Variable Array: TIFFTAG_DECODE is a SRATIONAL parameter TIFF_SETGET_C16_FLOAT type FIELD_CUSTOM with passcount=1 and variable length of array. */
- if (!TIFFSetField(tif, TIFFTAG_DECODE, 3, auxFloatArrayN2)) {
- fprintf(stderr, "Can't set TIFFTAG_DECODE tag.\n");
- goto failure;
- }
-
- /*- Varable Array: TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT */
- if (!TIFFSetField(tif, TIFFTAG_BLACKLEVEL, 3, auxFloatArrayN1)) {
- fprintf(stderr, "Can't set TIFFTAG_BLACKLEVEL tag.\n");
- goto failure;
- }
-
- /*- Fixed Array: TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT */
- if (!TIFFSetField(tif, TIFFTAG_DEFAULTCROPSIZE, &auxFloatArrayW[0])) {
- fprintf(stderr, "Can't set TIFFTAG_DEFAULTCROPSIZE tag.\n");
- goto failure;
- }
-#endif /* -- ADDITIONAL_TAGS -- */
-
-/*================== Rational2Double Interface Check =====================*/
- /*-- Check, if the TiffLibrary is compiled with the new interface with Rational2Double or still uses the old definitions.
- For that, TIFF_RATIONAL tags with FIELD_CUSTOM are changed from TIFF_SETGET_DOUBLE to TIFF_SETGET_FLOAT for the
- new interface in order to prevent the old reading behaviour.
- Tags to check: TIFFTAG_BESTQUALITYSCALE, TIFFTAG_BASELINENOISE, TIFFTAG_BASELINESHARPNESS
- */
- fip = TIFFFindField(tif, TIFFTAG_BESTQUALITYSCALE, TIFF_ANY);
- tSetFieldType = fip->set_field_type;
- if (tSetFieldType == TIFF_SETGET_DOUBLE) {
- blnIsRational2Double = FALSE;
- } else {
- blnIsRational2Double = TRUE;
- fprintf(stderr, "-- Rational2Double from TIFF tag detected --\n");
- }
-
-/*================== Write GPS and EXIF tags =====================*/
-
- /*-- Set dummy EXIF/GPS tag in original tiff-structure in order to reserve space for final dir_offset value, */
- /* which is properly written at the end. */
- dir_offset = 0; /* Zero, in case no Custom-IFD is written */
-
-#define WRITE_GPS_TAGS
-#ifdef WRITE_GPS_TAGS
- if (!TIFFSetField(tif, TIFFTAG_GPSIFD, dir_offset )) {
- fprintf (stderr, "Can't write TIFFTAG_GPSIFD\n" );
- }
-#endif
-
- /*------- And also do the same for the EXIF IFD tag here, because we have to save the main directory next ------*/
- /*-- Set dummy EXIF/GPS tag in original tiff-structure in order to reserve space for final dir_offset value,
- * which is properly written at the end.
- */
-#define WRITE_EXIF_TAGS
-#ifdef WRITE_EXIF_TAGS
- if (!TIFFSetField(tif, TIFFTAG_EXIFIFD, dir_offset )) {
- fprintf (stderr, "Can't write TIFFTAG_EXIFIFD\n" );
- }
-#endif
-
-#ifndef WRITEPIXELLAST
- /*-- Write dummy pixel data. --*/
- if (TIFFWriteScanline(tif, buf, 0, 0) < 0) {
- fprintf (stderr, "Can't write image data.\n");
- goto failure;
- }
-#endif
-
-
-#ifdef WRITE_GPS_TAGS
-#define READ_GPS_TAGS
- /*================== Write GPS tags =====================*/
-
- /*-- Save current tiff-directory to file before directory is changed. Otherwise it will be lost! */
- /* The tif-structure is overwritten/ freshly initialized by any "CreateDirectory" */
- /*retCode = TIFFCheckpointDirectory(tif);*/ /* does not cleanup Tiff-Structure */
- retCode = TIFFWriteDirectory(tif); /* cleanup Tiff-structure */
-
- /*-- Now create a GPS directory. */
- if (TIFFCreateGPSDirectory(tif) != 0) {
- fprintf (stderr, "TIFFCreateGPSDirectory() failed.\n" );
- goto failure;
- }
-
- if (!TIFFSetField( tif, GPSTAG_VERSIONID, gpsVersion)) {
- fprintf (stderr, "Can't write GPSTAG_VERSIONID\n" );
- goto failure;
- }
-
- if (blnFillGPSManually) {
- /*================= Write manually valid data to the GPS fields ==============*/
- if (!TIFFSetField( tif, GPSTAG_LATITUDEREF, "N\0")) {
- fprintf (stderr, "Can't write GPSTAG_LATITUDEREF\n" );
- goto failure;
- }
- /*-- Unfortunately, Rational values are defined as SETGET_DOUBLE but are internally always stored as float.
- * Single Rational values do not matter for writing, because TIFFSetField() uses va_arg() which performs "variables promotion" from type float to type double!
- * However, for reading of Rational values ONLY float-variables are allowed - in contrary to the SETGET_DOUBLE specification at tiffFields[] in tif_dirinfo.c.
- */
- /*-- ATTENTION: After the upgrade with Rational2Double, the GPSTAG values are defined as double precision
- * and need to be written and also read in double precision!
- * In order to maintain this code for both cases, it is checked above if the TiffLibrary is
- * compiled with the new interface with Rational2Double or still uses the old definitions,
- * by setting blnIsRational2Double above.
- */
- if (blnIsRational2Double) {
- fprintf(stderr, "-- GPS tags are written using Rational2Double --\n");
- } else {
- fprintf(stderr, "-- GPS tags are written using standard --\n");
- }
- if (!blnIsRational2Double) {
- for (j = 0; j < 3; j++) auxFloatArray[j] = (float)auxDoubleArrayGPS1[j];
- if (!TIFFSetField(tif, GPSTAG_LATITUDE, auxFloatArray)) {
- fprintf(stderr, "Can't write GPSTAG_LATITUDE\n");
- goto failure;
- }
- } else {
- /* Rational2Double interface for GPSTAG */
- if (!TIFFSetField(tif, GPSTAG_LATITUDE, auxDoubleArrayGPS1)) {
- fprintf(stderr, "Can't write GPSTAG_LATITUDE\n");
- goto failure;
- }
- }
- if (!TIFFSetField( tif, GPSTAG_LONGITUDEREF, "W\0")) {
- fprintf (stderr, "Can't write GPSTAG_LONGITUDEREF\n" );
- goto failure;
- }
- if (!blnIsRational2Double) {
- for (j=0; j<3; j++) auxFloatArray[j] = (float)auxDoubleArrayGPS2[j];
- if (!TIFFSetField( tif, GPSTAG_LONGITUDE, auxFloatArray)) {
- fprintf (stderr, "Can't write GPSTAG_LONGITUDE\n" );
- goto failure;
- }
- } else {
- /* Rational2Double interface for GPSTAG */
- if (!TIFFSetField(tif, GPSTAG_LONGITUDE, auxDoubleArrayGPS2)) {
- fprintf(stderr, "Can't write GPSTAG_LATITUDE\n");
- goto failure;
- }
- }
- /*-- AltitudeRef: default is above sea level!! */
- if (!TIFFSetField( tif, GPSTAG_ALTITUDEREF, 0)) {
- fprintf (stderr, "Can't write GPSTAG_ALTITUDEREF\n" );
- goto failure;
- }
- if (!TIFFSetField( tif, GPSTAG_ALTITUDE, auxDoubleGPSAltitude)) {
- fprintf (stderr, "Can't write GPSTAG_ALTITUDE\n" );
- goto failure;
- }
- /*-- TimeStamp is only hh:mm:ss. See also DateTime string */
- if (!TIFFSetField( tif, GPSTAG_TIMESTAMP, auxDoubleArrayGPSTime)) {
- fprintf (stderr, "Can't write GPSTAG_TIMESTAMP\n" );
- goto failure;
- }
- if (!TIFFSetField( tif, GPSTAG_DATESTAMP, "2012:11:04")) {
- fprintf (stderr, "Can't write GPSTAG_DATESTAMP\n" );
- goto failure;
- }
-
- if (!TIFFSetField( tif, GPSTAG_IMGDIRECTIONREF, "T\0")) {
- fprintf (stderr, "Can't write GPSTAG_IMGDIRECTIONREF\n" );
- goto failure;
- }
- if (!TIFFSetField( tif, GPSTAG_IMGDIRECTION, auxDoubleGPSDirection)) {
- fprintf (stderr, "Can't write GPSTAG_IMGDIRECTION\n" );
- goto failure;
- }
-
- /*-- Type TIFF_UNDEFINED */
- if (!TIFFSetField( tif, GPSTAG_PROCESSINGMETHOD, 3, &auxCharArrayW[10])) {
- fprintf (stderr, "Can't write GPSTAG_PROCESSINGMETHOD\n" );
- goto failure;
- }
- if (!TIFFSetField( tif, GPSTAG_AREAINFORMATION, 4, &auxCharArrayW[20])) {
- fprintf (stderr, "Can't write GPSTAG_AREAINFORMATION\n" );
- goto failure;
- }
-
- /*-- PSTAG_DIFFERENTIAL , 1, 1, TIFF_SHORT , 0, TIFF_SETGET_UINT16 */
- if (!TIFFSetField( tif, GPSTAG_DIFFERENTIAL, auxShortArrayW[5])) {
- fprintf (stderr, "Can't write GPSTAG_DIFFERENTIAL\n" );
- goto failure;
- }
-
- /* GPSTAG_GPSHPOSITIONINGERROR , 1, 1, TIFF_RATIONAL , 0, TIFF_SETGET_DOUBLE but here written in float-precision */
-#define GPSHPOSITIONINGERROR_VAL 0.369
- auxFloat = (float)GPSHPOSITIONINGERROR_VAL;
- if (!TIFFSetField( tif, GPSTAG_GPSHPOSITIONINGERROR, auxFloat)) {
- fprintf (stderr, "Can't write GPSTAG_GPSHPOSITIONINGERROR\n" );
- goto failure;
- }
-
- } else {
- /*================= Write arbitrary data to the GPS fields ==============*/
-
- /*-- Get array, where GPS tag fields are defined --*/
- tFieldArray = _TIFFGetGpsFields();
- nTags = tFieldArray->count;
-
- /*-- TODO: fill in the for / switch part of EXIF writing, when finished and tested!! */
-
- } /*-- if (blnFillGPSManually) --*/
-
-
-
-
- /*-- GPS - write custom directory GPS into file...---*/
- /* (Get back the offset of GPS directory) */
- if (!TIFFWriteCustomDirectory( tif, &dir_offset_GPS )) {
- fprintf (stderr, "TIFFWriteCustomDirectory() with GPS failed.\n");
- goto failure;
- }
-
- /*--- CheckpointDirectory at this place generates a second Main-IFD!!! */
- /* retCode = TIFFCheckpointDirectory(tif); */
-
- /*-- Set / reload previously saved main directory from file ---*/
- if (!TIFFSetDirectory(tif, 0)) {
- fprintf (stderr, "TIFFSetDirectory() within GPS failed.\n");
- goto failure;
- }
-
- /*-- Write GPS tag reference / offset into GPSIFD tag in main directory --*/
- if (!TIFFSetField(tif, TIFFTAG_GPSIFD, dir_offset_GPS )) {
- fprintf (stderr, "Can't write TIFFTAG_GPSIFD\n");
- goto failure;
- }
-
- /*=============== END writing GPS tags ==========================*/
-#endif /*-- WRITE_GPS_TAGS --*/
-
-
-/*================== Write EXIF 2.31 tags =====================*/
-
- /*-- Set dummy EXIF/GPS tag in original tiff-structure in order to reserve space for final dir_offset value, */
- /* which is properly written at the end.*/
- /*- We did this already above together with the GPS IFD-tag. Otherwise we would do this here !! --------*/
- /* if (!TIFFSetField(tif, TIFFTAG_EXIFIFD, dir_offset )) {
- fprintf (stderr, "Can't write TIFFTAG_EXIFIFD\n" );
- }
- */
-
-#ifdef WRITE_EXIF_TAGS
-#define READ_EXIF_TAGS
- /*-- Save current tiff-directory to file before directory is changed. Otherwise it will be lost!
- * The tif-structure is overwritten/ freshly initialized by any "CreateDirectory"
- */
-
- /*----- What is needed here ??? ----
- * In custom_dir.c only TIFFFreeDirectory( tif ); is used to set fields of another Sub-Directory
- * TIFFFreeDirectory(tif); *-- Release storage associated with a directory, especially custom-fields.
- *-- Using only TIFFFreeDirectory() here leads to an error!!
- *-- Using here TIFFCheckpointDirectory() leads to an additional Main-IFD ??
- */
- /*retCode = TIFFCheckpointDirectory(tif);*/ /* does not cleanup Tiff-Structure */
- retCode = TIFFWriteDirectory(tif); /* cleanup Tiff-structure */
-
- /*-- Now create an EXIF directory. */
- if (TIFFCreateEXIFDirectory(tif) != 0) {
- fprintf (stderr, "TIFFCreateEXIFDirectory() failed.\n" );
- goto failure;
- }
-
-#define WRITE_ALL_EXIF_TAGS
-#ifdef WRITE_ALL_EXIF_TAGS
-#define READ_ALL_EXIF_TAGS
- /*================= EXIF: Write arbitrary data to the EXIF fields ==============*/
- /*-- Get array, where EXIF tag fields are defined
- * EXIF tags are written automatically with the defined precision according to its tSetFieldType using the code below --*/
- tFieldArray = _TIFFGetExifFields();
- nTags = tFieldArray->count;
-
- for (i=0; i<nTags; i++) {
- tTag = tFieldArray->fields[i].field_tag;
- tType = tFieldArray->fields[i].field_type; /* e.g. TIFF_RATIONAL */
- tWriteCount = tFieldArray->fields[i].field_writecount;
- tSetFieldType = tFieldArray->fields[i].set_field_type; /* e.g. TIFF_SETGET_C0_FLOAT */
- tFieldName = tFieldArray->fields[i].field_name;
- pVoid = NULL;
-
- /*-- dependent on set_field_type write value --*/
- switch (tSetFieldType)
- {
- case TIFF_SETGET_ASCII:
- /* Either the stringlength is defined as a fixed length in .field_writecount or a NULL-terminated string is used. */
- /* Shorter strings than in auxTextArraxW need a NULL-termination. Therefore copy the string. */
- if (tWriteCount > 0) auxLong = tWriteCount-1; else auxLong = (long)strlen(auxTextArrayW[i])-1;
- strncpy(auxCharArray, auxTextArrayW[i], auxLong);
- auxCharArray[auxLong] = 0;
- if (!TIFFSetField( tif, tTag, auxCharArray)) {
- fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
- goto failure;
- }
- break;
- case TIFF_SETGET_UINT8:
- case TIFF_SETGET_UINT16:
- case TIFF_SETGET_UINT32:
- case TIFF_SETGET_IFD8:
- case TIFF_SETGET_INT:
- /*-- All those can be written with char, short or long parameter. Only value range should be in line. */
- if (!TIFFSetField( tif, tTag, auxLongArrayW[i])) {
- fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
- goto failure;
- }
- break;
- case TIFF_SETGET_SINT8:
- case TIFF_SETGET_SINT16:
- case TIFF_SETGET_SINT32:
- /*-- All those can be written with char, short or long parameter. Only value range should be in line. */
- if (!TIFFSetField( tif, tTag, -1.0*auxLongArrayW[i])) {
- fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
- goto failure;
- }
- break;
- case TIFF_SETGET_FLOAT:
- case TIFF_SETGET_DOUBLE:
- if (tWriteCount == 1) {
- /*-- All single values can be written with float or double parameter. Only value range should be in line. */
- if (!TIFFSetField( tif, tTag, auxDoubleArrayW[i])) {
- fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
- goto failure;
- }
- } else {
- fprintf (stderr, "WriteCount for .set_field_type %d should be 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name);
- }
- break;
- case TIFF_SETGET_C0_FLOAT:
- case TIFF_SETGET_C0_DOUBLE:
- case TIFF_SETGET_C16_FLOAT:
- case TIFF_SETGET_C16_DOUBLE:
- case TIFF_SETGET_C32_FLOAT:
- case TIFF_SETGET_C32_DOUBLE:
- /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */
- /*-- Check, if it is a single parameter, a fixed array or a variable array */
- if (tWriteCount == 1) {
- fprintf (stderr, "WriteCount for .set_field_type %d should be -1 or greather than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name);
- } else {
- /*-- Either fix or variable array --*/
- /* For arrays, distinguishing between float or double is essential, even for writing */
- if (tSetFieldType == TIFF_SETGET_C0_FLOAT || tSetFieldType == TIFF_SETGET_C16_FLOAT || tSetFieldType == TIFF_SETGET_C32_FLOAT)
- pVoid = &auxFloatArrayW[i]; else pVoid = &auxDoubleArrayW[i];
- /* Now decide between fixed or variable array */
- if (tWriteCount > 1) {
- /* fixed array with needed arraysize defined in .field_writecount */
- if (!TIFFSetField( tif, tTag, pVoid)) {
- fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
- goto failure;
- }
- } else {
- /* special treatment of variable array */
- /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */
- if (!TIFFSetField( tif, tTag, VARIABLE_ARRAY_SIZE, pVoid)) {
- fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
- goto failure;
- }
- }
- }
- break;
- case TIFF_SETGET_C0_UINT8:
- case TIFF_SETGET_C0_SINT8:
- case TIFF_SETGET_C16_UINT8:
- case TIFF_SETGET_C16_SINT8:
- case TIFF_SETGET_C32_UINT8:
- case TIFF_SETGET_C32_SINT8:
- /* For arrays, distinguishing between float or double is essential, even for writing */
- pVoid = &auxCharArrayW[i];
- case TIFF_SETGET_C0_UINT16:
- case TIFF_SETGET_C0_SINT16:
- case TIFF_SETGET_C16_UINT16:
- case TIFF_SETGET_C16_SINT16:
- case TIFF_SETGET_C32_UINT16:
- case TIFF_SETGET_C32_SINT16:
- if (pVoid == NULL) pVoid = &auxShortArrayW[i];
- case TIFF_SETGET_C0_UINT32:
- case TIFF_SETGET_C0_SINT32:
- case TIFF_SETGET_C16_UINT32:
- case TIFF_SETGET_C16_SINT32:
- case TIFF_SETGET_C32_UINT32:
- case TIFF_SETGET_C32_SINT32:
- if (pVoid == NULL) pVoid = &auxLongArrayW[i];
- /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */
- /*-- Check, if it is a single parameter, a fixed array or a variable array */
- if (tWriteCount == 1) {
- fprintf (stderr, "WriteCount for .set_field_type %d should be -1 or greather than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name);
- } else {
- /*-- Either fix or variable array --*/
- /* Now decide between fixed or variable array */
- if (tWriteCount > 1) {
- /* fixed array with needed arraysize defined in .field_writecount */
- if (!TIFFSetField( tif, tTag, pVoid)) {
- fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
- goto failure;
- }
- } else {
- /* special treatment of variable array */
- /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */
- if (!TIFFSetField( tif, tTag, VARIABLE_ARRAY_SIZE, pVoid)) {
- fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
- goto failure;
- }
- }
- }
- break;
- default:
- fprintf (stderr, "SetFieldType %d not defined within writing switch for %s.\n", tSetFieldType, tFieldName);
- }; /*-- switch() --*/
- } /*-- for() --*/
- /*================= EXIF: END Writing arbitrary data to the EXIF fields END END END ==============*/
-#endif /*-- WRITE_ALL_EXIF_TAGS --*/
-
- /*--- Set valid EXIF version, which is a 4 byte string --*/
- if (!TIFFSetField( tif, EXIFTAG_EXIFVERSION, exifVersion)) {
- fprintf (stderr, "Can't write EXIFTAG_EXIFVERSION\n" );
- goto failure;
- }
-
-
- /*-- EXIF - write custom directory EXIF into file...---*/
- /* (Get back the offset of EXIF directory) */
- if (!TIFFWriteCustomDirectory( tif, &dir_offset_EXIF )) {
- fprintf (stderr, "TIFFWriteCustomDirectory() with EXIF failed.\n");
- goto failure;
- }
-
- /*-- Go back to the first (main) directory, and set correct value of the EXIFIFD pointer. */
- /* (directory is reloaded from file!) */
- TIFFSetDirectory(tif, 0);
- TIFFSetField(tif, TIFFTAG_EXIFIFD, dir_offset_EXIF );
-#endif /*-- WRITE_EXIF_TAGS --*/
-
-#ifdef WRITEPIXELLAST
- /*-- Write dummy pixel data. --*/
- if (TIFFWriteScanline(tif, buf, 0, 0) < 0) {
- fprintf (stderr, "Can't write image data.\n");
- goto failure;
- }
-#endif
- /*-- Write directory to file --*/
- /* Always WriteDirectory before using/creating another directory. */
- /* Not necessary before TIFFClose(), however, TIFFClose() uses TIFFReWriteDirectory(), which forces directory to be written at another location. */
- retCode = TIFFWriteDirectory(tif);
-
- /*-- Write File to disk and close file --*/
- /* TIFFClose() uses TIFFReWriteDirectory(), which forces directory to be written at another location. */
- /* Therefore, better use TIFFWriteDirectory() before. */
- TIFFClose(tif);
-
- fprintf (stderr, "-------- Continue Test ---------- reading ...\n");
-
-/*========================= READING ============= READING ========================================*/
- /* Ok, now test whether we can read written values correctly. */
- tif = TIFFOpen(filenameRead, "r");
-
-
- /*-- Read some parameters out of the main directory --*/
-
- /*-- IMAGEWIDTH and -LENGTH are defined as TIFF_SETGET_UINT32 */
- retCode = TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &auxUint32 );
- if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_IMAGEWIDTH"); }
- if (auxUint32 != width) {
- fprintf (stderr, "Read value of IMAGEWIDTH %d differs from set value %d\n", auxUint32, width);
- }
- retCode = TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &auxUint32 );
- if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_IMAGELENGTH"); }
- if (auxUint32 != width) {
- fprintf (stderr, "Read value of TIFFTAG_IMAGELENGTH %d differs from set value %d\n", auxUint32, length);
- }
-
-#ifdef ADDITIONAL_TAGS
- /*- TIFFTAG_PIXAR_FOVCOT is a FLOAT parameter of type FIELD_CUSTOM !! */
- retCode = TIFFGetField(tif, TIFFTAG_PIXAR_FOVCOT, &auxFloat );
- if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_PIXAR_FOVCOT"); }
- if (auxFloat != (float)PIXAR_FOVCOT_VAL) {
- fprintf (stderr, "Read value of TIFFTAG_PIXAR_FOVCOT %f differs from set value %f\n", auxFloat, PIXAR_FOVCOT_VAL);
- }
-
- /* - TIFFTAG_BESTQUALITYSCALE is a Rational parameter, FIELD_CUSTOM and TIFF_SETGET_FLOAT */
- retCode = TIFFGetField(tif, TIFFTAG_BESTQUALITYSCALE, &auxFloat );
- if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_BESTQUALITYSCALE"); }
- if (auxFloat != (float)BESTQUALITYSCALE_VAL) {
- fprintf (stderr, "Read value of TIFFTAG_BESTQUALITYSCALE %f differs from set value %f\n", auxFloat, BESTQUALITYSCALE_VAL);
- }
-
- /* - TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT */
- retCode = TIFFGetField(tif, TIFFTAG_BASELINENOISE, &auxDblUnion.dbl);
- if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_BASELINENOISE"); }
- if (auxDblUnion.flt1 != (float)BESTQUALITYSCALE_VAL) {
- fprintf(stderr, "Read float value of TIFFTAG_BASELINENOISE %f differs from set value %f\n", auxDblUnion.flt1, BESTQUALITYSCALE_VAL);
- }
-
-
- /*- Variable Array: TIFFTAG_DECODE is a SRATIONAL parameter TIFF_SETGET_C16_FLOAT type FIELD_CUSTOM with passcount=1 and variable length of array. */
- retCode = TIFFGetField(tif, TIFFTAG_DECODE, &count16, &pVoidArray );
- if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_DECODE"); }
- /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, contents needs to be saved. */
- memcpy(&auxFloatArray, pVoidArray,(count16 * sizeof(auxFloatArray[0])));
- for (i=0; i<count16; i++) {
- dblDiffLimit = RATIONAL_EPS*auxFloatArrayN2[i];
- dblDiff = auxFloatArray[i] - auxFloatArrayN2[i];
- if (fabs(dblDiff) > fabs(dblDiffLimit)) {
- fprintf (stderr, "Read value %d of TIFFTAG_DECODE Array %f differs from set value %f\n", i, auxFloatArray[i], auxFloatArrayN2[i]);
- }
- }
-
- retCode = TIFFGetField(tif, TIFFTAG_BLACKLEVEL, &count16, &pVoidArray);
- if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_BLACKLEVEL"); }
- /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, contents needs to be saved. */
- memcpy(&auxFloatArray, pVoidArray, (count16 * sizeof(auxFloatArray[0])));
- for (i = 0; i<count16; i++) {
- dblDiffLimit = RATIONAL_EPS*auxFloatArrayN1[i];
- dblDiff = auxFloatArray[i] - auxFloatArrayN1[i];
- if (fabs(dblDiff) > fabs(dblDiffLimit)) {
- fprintf(stderr, "Read value %d of TIFFTAG_BLACKLEVEL Array %f differs from set value %f\n", i, auxFloatArray[i], auxFloatArrayN1[i]);
- }
- }
-
- /*- Fixed Array: TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT */
- retCode = TIFFGetField(tif, TIFFTAG_DEFAULTCROPSIZE, &pVoidArray);
- if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_DEFAULTCROPSIZE"); }
- /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, contents needs to be saved. */
- memcpy(&auxFloatArray, pVoidArray, (2 * sizeof(auxFloatArray[0])));
- for (i = 0; i < 2; i++) {
- dblDiffLimit = RATIONAL_EPS * auxFloatArrayW[i];
- dblDiff = auxFloatArray[i] - auxFloatArrayW[i];
- if (fabs(dblDiff) > fabs(dblDiffLimit)) {
- fprintf(stderr, "Read value %d of TIFFTAG_DEFAULTCROPSIZE Array %f differs from set value %f\n", i, auxFloatArray[i], auxFloatArrayW[i]);
- }
- }
-
-#endif /*-- ADDITIONAL_TAGS --*/
-
-
-#ifdef READ_GPS_TAGS
-/*================== Reading GPS tags =====================*/
- /*-- First get offset to GPS-directory and set it active (this will destroy previously main directory fields in memory!) */
- retCode = TIFFGetField(tif, TIFFTAG_GPSIFD, &read_dir_offset );
- if (!retCode) {fprintf(stderr, "Can't read %s\n", "TIFFTAG_GPSIFD"); }
- retCode = TIFFReadGPSDirectory(tif, read_dir_offset);
- if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFReadGPSDirectory()"); }
-
- /*-- Now read some parameters from GPS-directory --*/
-
- /*-- Fixed Array: GPS-Version is a fixed array (of 4 characters) */
- retCode = TIFFGetField(tif, GPSTAG_VERSIONID, &pGpsVersion);
- if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_VERSIONID"); }
- else {
- memcpy(auxCharArray, pGpsVersion, sizeof(gpsVersion));
- for (i = 0; i < 4; i++) {
- if (auxCharArray[i] != pGpsVersion[i]) {
- fprintf(stderr, "Read value %d of GPSTAG_VERSIONID %d differs from set value %d\n", i, auxCharArray[i], pGpsVersion[i]);
- }
- }
- }
- /*-- LATITUDEREF is a fixed String of one character plus ending zero. */
- retCode = TIFFGetField(tif, GPSTAG_LATITUDEREF, &pAscii);
- if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_LATITUDEREF"); }
- retCode2 = strncmp("N", pAscii, 1);
- if (retCode2 != 0) {
- fprintf (stderr, "Read value %d of GPSTAG_LATITUDEREF %s differs from set value %s\n", i, "N", pAscii);
- }
-
- /*-- Fixed Array: Latitude is an array of 3 Rational-values. TIFFGetField() returns a pointer to a temporary float-/double-array. */
- /*-- ATTENTION: After the upgrade with Rational2Double, the GPSTAG values are defined as double precision
- * and need to be written and also read in double precision!
- * In order to maintain this code for both cases, it is checked above if the TiffLibrary is
- * compiled with the new interface with Rational2Double or still uses the old definitions,
- * by setting blnIsRational2Double above.
- */
- if (blnIsRational2Double) {
- fprintf(stderr, "-- GPS tags are read using Rational2Double --\n");
- } else {
- fprintf(stderr, "-- GPS tags are read using standard --\n");
- }
- retCode = TIFFGetField(tif, GPSTAG_LATITUDE, &pVoidArray);
- if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_LATITUDE"); }
- if (!blnIsRational2Double) {
- /* Reset arrays for debugging purpose first */
- memset(auxFloatArray, 0, sizeof(auxFloatArray));
- memcpy(auxFloatArray, pVoidArray, 3*sizeof(float));
- /* for comparison copy to doubleArray */
- for (i=0; i<3; i++) auxDoubleArray[i] = (double)auxFloatArray[i];
- } else {
- /* Rational2Double interface for GPSTAG reads double array */
- memset(auxDoubleArray, 0, sizeof(auxDoubleArray));
- memcpy(auxDoubleArray, pVoidArray, 3 * sizeof(double));
- }
- for (i=0; i<3; i++) {
- dblDiffLimit = RATIONAL_EPS*auxDoubleArrayGPS1[i];
- dblDiff = auxDoubleArray[i] - auxDoubleArrayGPS1[i];
- if (fabs(dblDiff) > fabs(dblDiffLimit)) {
- fprintf (stderr, "Read value %d of GPSTAG_LATITUDE %f differs from set value %f\n", i, auxDoubleArray[i], auxDoubleArrayGPS1[i]);
- }
- }
-
- /*-- LONGITUDEREF is a fixed String of one character plus ending zero. */
- retCode = TIFFGetField(tif, GPSTAG_LONGITUDEREF, &pAscii);
- if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_LONGITUDEREF"); }
- retCode2 = strncmp("W", pAscii, 1);
- if (retCode2 != 0) {
- fprintf(stderr, "Read value %d of GPSTAG_LONGITUDEREF %s differs from set value %s\n", i, "W", pAscii);
- }
-
- retCode = TIFFGetField(tif, GPSTAG_LONGITUDE, &pVoidArray);
- if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_LONGITUDE"); }
- if (!blnIsRational2Double) {
- /* Reset arrays for debugging purpose first */
- memset(auxFloatArray, 0, sizeof(auxFloatArray));
- memcpy(auxFloatArray, pVoidArray, 3 * sizeof(float));
- /* for comparison copy to doubleArray */
- for (i = 0; i < 3; i++) auxDoubleArray[i] = (double)auxFloatArray[i];
- } else {
- /* Rational2Double interface for GPSTAG reads double array */
- memset(auxDoubleArray, 0, sizeof(auxDoubleArray));
- memcpy(auxDoubleArray, pVoidArray, 3 * sizeof(double));
- }
- for (i = 0; i < 3; i++) {
- dblDiffLimit = RATIONAL_EPS * auxDoubleArrayGPS2[i];
- dblDiff = auxDoubleArray[i] - auxDoubleArrayGPS2[i];
- if (fabs(dblDiff) > fabs(dblDiffLimit)) {
- fprintf(stderr, "Read value %d of GPSTAG_LONGITUDE %f differs from set value %f\n", i, auxDoubleArray[i], auxDoubleArrayGPS2[i]);
- }
- }
-
- /* TIFF_RATIONAL, TIFF_SETGET_DOUBLE */
- if (!TIFFGetField(tif, GPSTAG_ALTITUDE, &auxDblUnion.dbl)) {
- fprintf(stderr, "Can't read GPSTAG_ALTITUDE\n");
- GOTOFAILURE_GPS
- }
- if (blnIsRational2Double) {
- /* New interface allows also double precision for TIFF_RATIONAL */
- auxDouble = auxDblUnion.dbl;
- } else {
- /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE alwasy as FLOAT */
- auxDouble = (double)auxDblUnion.flt1;
- }
- /* compare read values with written ones */
- dblDiffLimit = RATIONAL_EPS * auxDoubleGPSAltitude;
- dblDiff = auxDouble - auxDoubleGPSAltitude;
- if (fabs(dblDiff) > fabs(dblDiffLimit)) {
- fprintf(stderr, "Read value of GPSTAG_ALTITUDE %f differs from set value %f\n", auxDouble, auxDoubleGPSAltitude);
- GOTOFAILURE_GPS
- }
-
- /*-- TimeStamp is only hh:mm:ss. See also DateTime string 3, TIFF_RATIONAL, TIFF_SETGET_C0_DOUBLE */
- retCode = TIFFGetField(tif, GPSTAG_TIMESTAMP, &pVoidArray);
- if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_TIMESTAMP"); }
- if (!blnIsRational2Double) {
- /* Reset arrays for debugging purpose first */
- memset(auxFloatArray, 0, sizeof(auxFloatArray));
- memcpy(auxFloatArray, pVoidArray, 3 * sizeof(float));
- /* for comparison copy to doubleArray */
- for (i = 0; i < 3; i++) auxDoubleArray[i] = (double)auxFloatArray[i];
- } else {
- /* Rational2Double interface for GPSTAG reads double array */
- memset(auxDoubleArray, 0, sizeof(auxDoubleArray));
- memcpy(auxDoubleArray, pVoidArray, 3 * sizeof(double));
- }
- for (i = 0; i < 3; i++) {
- dblDiffLimit = RATIONAL_EPS * auxDoubleArrayGPSTime[i];
- dblDiff = auxDoubleArray[i] - auxDoubleArrayGPSTime[i];
- if (fabs(dblDiff) > fabs(dblDiffLimit)) {
- fprintf(stderr, "Read value %d of GPSTAG_TIMESTAMP %f differs from set value %f\n", i, auxDoubleArray[i], auxDoubleArrayGPS2[i]);
- GOTOFAILURE_GPS
- }
- }
-
- /* GPSTAG_IMGDIRECTION --- TIFF_RATIONAL, TIFF_SETGET_DOUBLE */
- if (!TIFFGetField(tif, GPSTAG_IMGDIRECTION, &auxDblUnion.dbl)) {
- fprintf(stderr, "Can't read GPSTAG_IMGDIRECTION\n");
- GOTOFAILURE_GPS
- }
- if (blnIsRational2Double) {
- /* New interface allows also double precision for TIFF_RATIONAL */
- auxDouble = auxDblUnion.dbl;
- } else {
- /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE alwasy as FLOAT */
- auxDouble = (double)auxDblUnion.flt1;
- }
- /* compare read values with written ones */
- dblDiffLimit = RATIONAL_EPS * auxDoubleGPSDirection;
- dblDiff = auxDouble - auxDoubleGPSDirection;
- if (fabs(dblDiff) > fabs(dblDiffLimit)) {
- fprintf(stderr, "Read value of GPSTAG_IMGDIRECTION %f differs from set value %f\n", auxDouble, auxDoubleGPSDirection);
- GOTOFAILURE_GPS
- }
-
- /*-- GPSTAG_DIFFERENTIAL , 1, 1, TIFF_SHORT , 0, TIFF_SETGET_UINT16 */
- retCode = TIFFGetField(tif, GPSTAG_DIFFERENTIAL, &auxShort);
- if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_DIFFERENTIAL"); }
- if (auxShort != auxShortArrayW[5]) {
- fprintf(stderr, "Read value of GPSTAG_DIFFERENTIAL %d differs from set value %d\n", auxShort, auxShortArrayW[5]);
- GOTOFAILURE_GPS
- }
-
- /*-- GPSHPOSITIONINGERROR - new tag for EXIF 2.31 --*/
- if (!TIFFGetField(tif, GPSTAG_GPSHPOSITIONINGERROR, &auxDblUnion.dbl)) {
- fprintf(stderr, "Can't read GPSTAG_GPSHPOSITIONINGERROR\n");
- GOTOFAILURE_GPS
- }
- if (blnIsRational2Double) {
- /* New interface allows also double precision for TIFF_RATIONAL */
- auxDouble = auxDblUnion.dbl;
- } else {
- /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE alwasy as FLOAT */
- auxDouble = (double)auxDblUnion.flt1;
- }
- /* compare read values with written ones */
- auxFloat = (float)GPSHPOSITIONINGERROR_VAL;
- dblDiffLimit = RATIONAL_EPS * auxFloat;
- dblDiff = auxDouble - auxFloat;
- if (fabs(dblDiff) > fabs(dblDiffLimit)) {
- fprintf(stderr, "Read value of GPSTAG_GPSHPOSITIONINGERROR %f differs from set value %f\n", auxDouble, auxFloat);
- GOTOFAILURE_GPS
- }
-
- /*=============== END reading GPS tags ==========================*/
-#endif /*-- READ_GPS_TAGS --*/
-
-
-
-/*================== Reading EXIF 2.31 tags =====================*/
-
- /*--- Firstly, get EXIF directory offset from main directory. */
-
- /*-- Go back to the first (main) directory, and get value of the EXIFIFD directory- offset. */
- /* (directory is reloaded from file!) */
- TIFFSetDirectory(tif, 0);
- retCode = TIFFGetField(tif, TIFFTAG_EXIFIFD, &read_dir_offset );
-
-#ifdef READ_EXIF_TAGS
- /*-- Now read EXIF directory from file into memory --*/
- retCode = TIFFReadEXIFDirectory(tif, read_dir_offset);
-
- /*-- Now get some parameters from EXIF-directory (already read into memory) --*/
- retCode = TIFFGetField(tif, EXIFTAG_EXIFVERSION, &pAscii);
-
-
-#ifdef READ_ALL_EXIF_TAGS
- /*-- Get array, where EXIF tag fields are defined --*/
- tFieldArray = _TIFFGetExifFields();
- nTags = tFieldArray->count;
- /*-- Check, if the TiffLibrary is compiled with the new interface with Rational2Double or still uses the old definitions. */
- /* tif points to EXIF tags, so TIFFFindField() can only access the EXIF tag fields */
- fip = TIFFFindField(tif, EXIFTAG_EXPOSURETIME, TIFF_ANY);
- tSetFieldType = fip->set_field_type;
- if (tSetFieldType == TIFF_SETGET_DOUBLE) {
- blnIsRational2Double = FALSE;
- fprintf(stderr, "-- EXIF tags read with standard --\n");
- } else {
- blnIsRational2Double = TRUE;
- fprintf(stderr, "-- Rational2Double for reading EXIF tags detected --\n");
- }
-
- for (i=0; i<nTags; i++) {
- tTag = tFieldArray->fields[i].field_tag;
- tType = tFieldArray->fields[i].field_type; /* e.g. TIFF_RATIONAL */
- tWriteCount = tFieldArray->fields[i].field_writecount;
- tSetFieldType = tFieldArray->fields[i].set_field_type; /* e.g. TIFF_SETGET_C0_FLOAT */
- tFieldName = tFieldArray->fields[i].field_name;
- pVoid = NULL;
-
- /*-- dependent on set_field_type read value --*/
- switch (tSetFieldType)
- {
- case TIFF_SETGET_ASCII:
- /* Either the stringlength is defined as a fixed length in .field_writecount or a NULL-terminated string is used. */
- if (!TIFFGetField( tif, tTag, &pAscii)) {
- fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
- GOTOFAILURE_ALL_EXIF
- break;
- }
- /* Save string from temporary buffer and compare with written string. */
- strncpy(auxCharArray, pAscii, sizeof(auxCharArray));
- if (tWriteCount > 0) auxLong = tWriteCount-1; else auxLong = (long)strlen(auxCharArray);
- retCode2 = strncmp(auxCharArray, auxTextArrayW[i], auxLong);
- if (retCode2 != 0) {
- fprintf (stderr, "%d:Read value of %s %s differs from set value %s\n", i, tFieldName, auxCharArray, auxTextArrayW[i]);
- GOTOFAILURE_ALL_EXIF
- }
- break;
- /*-- For reading, the parameter size is to be observed !! */
- case TIFF_SETGET_UINT8:
- case TIFF_SETGET_SINT8:
- if (!TIFFGetField( tif, tTag, &auxChar)) {
- fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
- GOTOFAILURE_ALL_EXIF
- break;
- }
- /* compare read values with written ones */
- auxLong = auxChar;
- if (auxLong != (char)auxLongArrayW[i]) {
- fprintf (stderr, "%d:Read value of %s %ld differs from set value %ld\n", i, tFieldName, auxLong, auxLongArrayW[i]);
- }
- break;
- case TIFF_SETGET_UINT16:
- case TIFF_SETGET_SINT16:
- if (!TIFFGetField( tif, tTag, &auxShort)) {
- fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
- GOTOFAILURE_ALL_EXIF
- break;
- }
- /* compare read values with written ones */
- auxLong = auxShort;
- if (auxLong != (short)auxLongArrayW[i]) {
- fprintf (stderr, "%d:Read value of %s %ld differs from set value %ld\n", i, tFieldName, auxLong, auxLongArrayW[i]);
- }
- break;
- case TIFF_SETGET_UINT32:
- case TIFF_SETGET_SINT32:
- case TIFF_SETGET_IFD8:
- case TIFF_SETGET_INT:
- if (!TIFFGetField( tif, tTag, &auxUint32)) {
- fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
- GOTOFAILURE_ALL_EXIF
- break;
- }
- /* compare read values with written ones */
- auxLong = auxUint32;
- if (auxLong != auxLongArrayW[i]) {
- fprintf (stderr, "%d:Read value of %s %ld differs from set value %ld\n", i, tFieldName, auxLong, auxLongArrayW[i]);
- }
- break;
- case TIFF_SETGET_FLOAT:
- if (!TIFFGetField( tif, tTag, &auxFloat)) {
- fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
- GOTOFAILURE_ALL_EXIF
- break;
- }
- /* compare read values with written ones */
- if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) dblDiffLimit = RATIONAL_EPS*auxDoubleArrayW[i]; else dblDiffLimit = 1e-6;
- dblDiff = auxFloat - auxDoubleArrayW[i];
- if (fabs(dblDiff) > fabs(dblDiffLimit)) {
- /*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value of "-1.0" if numerator equals 4294967295 (0xFFFFFFFF) to indicate infinite distance!
- * However, there are two other EXIF tags where numerator indicates a special value and six other cases where the denominator indicates special values,
- * which are not treated within LibTiff!!
- */
- if (!(tTag == EXIFTAG_SUBJECTDISTANCE && auxFloat == -1.0)) {
- fprintf (stderr, "%d:Read value of %s %f differs from set value %f\n", i, tFieldName, auxFloat, auxDoubleArrayW[i]);
- GOTOFAILURE_ALL_EXIF
- }
- }
- break;
- case TIFF_SETGET_DOUBLE:
- /*-- Unfortunately, TIFF_SETGET_DOUBLE is used for TIFF_RATIONAL but those have to be read with FLOAT !!! */
- /* Only TIFFTAG_STONITS is a TIFF_DOUBLE, which has to be read as DOUBLE!! */
- /*-- ATTENTION: ----
- * Only after update with Rational2Double feature, also TIFF_RATIONAL can be read in double precision!!!
- * Therefore, use a union to avoid overflow in TIFFGetField() return value
- * and depending on version check for the right interface here:
- * - old interface: correct value should be here a float
- * - new interface: correct value should be here a double
- * Interface version (old/new) is determined above.
- -------------------*/
- if (!TIFFGetField(tif, tTag, &auxDblUnion.dbl)) {
- fprintf(stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
- GOTOFAILURE_ALL_EXIF
- break;
- }
- if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) {
- if (blnIsRational2Double) {
- /* New interface allows also double precision for TIFF_RATIONAL */
- auxDouble = auxDblUnion.dbl;
- }
- else {
- /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE alwasy as FLOAT */
- auxDouble = (double)auxDblUnion.flt1;
- }
- }
- else {
- auxDouble = auxDblUnion.dbl;
- }
- /* compare read values with written ones */
- if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) dblDiffLimit = RATIONAL_EPS*auxDoubleArrayW[i]; else dblDiffLimit = 1e-6;
- dblDiff = auxDouble - auxDoubleArrayW[i];
- if (fabs(dblDiff) > fabs(dblDiffLimit)) {
- /*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value of "-1.0" if numerator equals 4294967295 (0xFFFFFFFF) to indicate infinite distance! */
- if (!(tTag == EXIFTAG_SUBJECTDISTANCE && auxDouble == -1.0)) {
- fprintf (stderr, "%d:Read value of %s %f differs from set value %f\n", i, tFieldName, auxDouble, auxDoubleArrayW[i]);
- GOTOFAILURE_ALL_EXIF
- }
- }
- break;
-
- case TIFF_SETGET_C0_FLOAT:
- case TIFF_SETGET_C0_DOUBLE:
- case TIFF_SETGET_C16_FLOAT:
- case TIFF_SETGET_C16_DOUBLE:
- case TIFF_SETGET_C32_FLOAT:
- case TIFF_SETGET_C32_DOUBLE:
- /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */
- /*-- Check, if it is a single parameter, a fixed array or a variable array */
- if (tWriteCount == 1) {
- fprintf (stderr, "Reading: WriteCount for .set_field_type %d should be -1 or greather than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name);
- } else {
- /*-- Either fix or variable array --*/
- /* For arrays, distinguishing between float or double is essential. */
- /* Now decide between fixed or variable array */
- if (tWriteCount > 1) {
- /* fixed array with needed arraysize defined in .field_writecount */
- if (!TIFFGetField( tif, tTag, &pVoidArray)) {
- fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
- GOTOFAILURE_ALL_EXIF
- break;
- }
- /* set tWriteCount to number of read samples for next steps */
- auxLong = tWriteCount;
- } else {
- /* Special treatment of variable array. */
- /* Dependent on Cxx, the count parameter is char, short or long. Therefore use unionLong! */
- if (!TIFFGetField( tif, tTag, &unionLong, &pVoidArray)) {
- fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
- GOTOFAILURE_ALL_EXIF
- break;
- }
- /* set tWriteCount to number of read samples for next steps */
- auxLong = unionLong.Short1;
- }
- /* Save values from temporary array */
- if (tSetFieldType == TIFF_SETGET_C0_FLOAT || tSetFieldType == TIFF_SETGET_C16_FLOAT || tSetFieldType == TIFF_SETGET_C32_FLOAT) {
- memcpy(&auxFloatArray, pVoidArray,(auxLong * sizeof(auxFloatArray[0])));
- /* compare read values with written ones */
- if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) dblDiffLimit = RATIONAL_EPS*auxDoubleArrayW[i]; else dblDiffLimit = 1e-6;
- for (j=0; j<auxLong; j++) {
- dblDiff = auxFloatArray[j] - auxFloatArrayW[i+j];
- if (fabs(dblDiff) > fabs(dblDiffLimit)) {
- /*if (auxFloatArray[j] != (float)auxFloatArrayW[i+j]) { */
- fprintf (stderr, "Read value %d of %s #%d %f differs from set value %f\n", i, tFieldName, j, auxFloatArray[j], auxFloatArrayW[i+j]);
- GOTOFAILURE_ALL_EXIF
- }
- }
- } else {
- memcpy(&auxDoubleArray, pVoidArray,(auxLong * sizeof(auxDoubleArray[0])));
- /* compare read values with written ones */
- if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) dblDiffLimit = RATIONAL_EPS*auxDoubleArrayW[i]; else dblDiffLimit = 1e-6;
- for (j=0; j<auxLong; j++) {
- dblDiff = auxDoubleArray[j] - auxDoubleArrayW[i+j];
- if (fabs(dblDiff) > fabs(dblDiffLimit)) {
- /*if (auxDoubleArray[j] != auxDoubleArrayW[i+j]) { */
- fprintf (stderr, "Read value %d of %s #%d %f differs from set value %f\n", i, tFieldName, j, auxDoubleArray[j], auxDoubleArrayW[i+j]);
- GOTOFAILURE_ALL_EXIF
- }
- }
- }
- }
- break;
- case TIFF_SETGET_C0_UINT8:
- case TIFF_SETGET_C0_SINT8:
- case TIFF_SETGET_C16_UINT8:
- case TIFF_SETGET_C16_SINT8:
- case TIFF_SETGET_C32_UINT8:
- case TIFF_SETGET_C32_SINT8:
- /* For arrays, distinguishing between float or double is essential, even for writing */
- pVoid = &auxCharArrayW[i];
- case TIFF_SETGET_C0_UINT16:
- case TIFF_SETGET_C0_SINT16:
- case TIFF_SETGET_C16_UINT16:
- case TIFF_SETGET_C16_SINT16:
- case TIFF_SETGET_C32_UINT16:
- case TIFF_SETGET_C32_SINT16:
- if (pVoid == NULL) pVoid = &auxShortArrayW[i];
- case TIFF_SETGET_C0_UINT32:
- case TIFF_SETGET_C0_SINT32:
- case TIFF_SETGET_C16_UINT32:
- case TIFF_SETGET_C16_SINT32:
- case TIFF_SETGET_C32_UINT32:
- case TIFF_SETGET_C32_SINT32:
- if (pVoid == NULL) pVoid = &auxLongArrayW[i];
- /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */
- /*-- Check, if it is a single parameter, a fixed array or a variable array */
- if (tWriteCount == 1) {
- fprintf (stderr, "WriteCount for .set_field_type %d should be -1 or greather than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name);
- } else {
- /*-- Either fix or variable array --*/
- /* Now decide between fixed or variable array */
- if (tWriteCount > 1) {
- /* fixed array with needed arraysize defined in .field_writecount */
- if (!TIFFGetField( tif, tTag, &pVoidArray)) {
- fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
- GOTOFAILURE_ALL_EXIF
- break;
- }
- /* set tWriteCount to number of read samples for next steps */
- auxLong = tWriteCount;
- } else {
- /* special treatment of variable array */
- /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */
- if (!TIFFGetField( tif, tTag, &unionLong, &pVoidArray)) {
- fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
- GOTOFAILURE_ALL_EXIF
- break;
- }
- /* set tWriteCount to number of read samples for next steps */
- auxLong = unionLong.Short1;
- }
- /* Save values from temporary array */
- if (tSetFieldType == TIFF_SETGET_C0_UINT8 || tSetFieldType == TIFF_SETGET_C0_SINT8 ||
- tSetFieldType == TIFF_SETGET_C16_UINT8 || tSetFieldType == TIFF_SETGET_C16_SINT8 ||
- tSetFieldType == TIFF_SETGET_C32_UINT8 || tSetFieldType == TIFF_SETGET_C32_SINT8 ) {
- memcpy(&auxCharArray, pVoidArray,(auxLong * sizeof(auxCharArray[0])));
- /* Compare and check values */
- for (j=0; j<auxLong; j++) {
- if (tTag == EXIFTAG_EXIFVERSION) {
- /*-- Use exifVersion[] instead of auxCharArrayW[] for differently set EXIFVERSION tag */
- if (auxCharArray[j] != exifVersion[j]) {
- fprintf(stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, j, auxCharArray[j], auxCharArrayW[i + j]);
- GOTOFAILURE_ALL_EXIF
- }
- } else {
- if (auxCharArray[j] != auxCharArrayW[i + j]) {
- fprintf(stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, j, auxCharArray[j], auxCharArrayW[i + j]);
- GOTOFAILURE_ALL_EXIF
- }
- }
- }
- } else if (tSetFieldType == TIFF_SETGET_C0_UINT16 || tSetFieldType == TIFF_SETGET_C0_SINT16 ||
- tSetFieldType == TIFF_SETGET_C16_UINT16 || tSetFieldType == TIFF_SETGET_C16_SINT16 ||
- tSetFieldType == TIFF_SETGET_C32_UINT16 || tSetFieldType == TIFF_SETGET_C32_SINT16 ) {
- memcpy(&auxShortArray, pVoidArray,(auxLong * sizeof(auxShortArray[0])));
- /* Compare and check values */
- for (j=0; j<auxLong; j++) {
- if (auxShortArray[j] != auxShortArrayW[i+j]) {
- fprintf (stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, j, auxShortArray[j], auxShortArrayW[i+j]);
- GOTOFAILURE_ALL_EXIF
- }
- }
- } else if (tSetFieldType == TIFF_SETGET_C0_UINT32 || tSetFieldType == TIFF_SETGET_C0_SINT32 ||
- tSetFieldType == TIFF_SETGET_C16_UINT32 || tSetFieldType == TIFF_SETGET_C16_SINT32 ||
- tSetFieldType == TIFF_SETGET_C32_UINT32 || tSetFieldType == TIFF_SETGET_C32_SINT32 ) {
- memcpy(&auxLongArray, pVoidArray,(auxLong * sizeof(auxLongArray[0])));
- /* Compare and check values */
- for (j=0; j<auxLong; j++) {
- if (auxLongArray[j] != auxLongArrayW[i+j]) {
- fprintf (stderr, "Read value %d of %s #%d %ld differs from set value %ld\n", i, tFieldName, j, auxLongArray[j], auxLongArrayW[i+j]);
- GOTOFAILURE_ALL_EXIF
- }
- }
- } else {
- fprintf (stderr, "SetFieldType %d not defined within switch case reading for UINT for %s.\n", tSetFieldType, tFieldName);
- GOTOFAILURE
- }
- }
- break;
- default:
- fprintf (stderr, "SetFieldType %d not defined within writing switch for %s.\n", tSetFieldType, tFieldName);
- GOTOFAILURE
- }; /*-- switch() --*/
- } /*-- for() --*/
- /*================= EXIF: END Reading arbitrary data to the EXIF fields END END END ==============*/
-#endif /*-- READ_ALL_EXIF_TAGS --*/
-#endif /*-- READ_EXIF_TAGS --*/
-
-
-
-
- TIFFClose(tif);
-
- /* All tests passed; delete file and exit with success status. */
-#ifdef FOR_AUTO_TESTING
- unlink(filenameRead);
-#endif
- fprintf(stderr, "-------- Test finished OK ----------\n");
- return 0;
-
-failure:
- /*
- * Something goes wrong; close file and return unsuccessful status.
- * Do not remove the file for further manual investigation.
- */
- TIFFClose(tif);
- fprintf(stderr, "-------- Test finished with FAILURE --------\n");
- return 1;
-}
+/*
+ * Copyright (c) 2012, Frank Warmerdam <warmerdam@pobox.com>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the names of
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Sam Leffler and Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+/*
+ * TIFF Library
+ *
+ * -- Module copied from custom_dir.c --
+ *=========== Purpose ===================================================================================
+ * Extended and amended version for testing of EXIF 2.32, GPS and handling of custom fields.
+ * EXIF 2.32 and GPS are defined in amended files tif_dirinfo.c, tif_dirread.c, tiff.h, tiffio.h, tif_dir.h, tif_dir.c
+ *
+ *-- ATTENTION: After the upgrade with Rational2Double, the GPSTAG values are defined as double precision
+ * and need to be written and also read in double precision!
+ * In order to maintain this code for both cases, it is checked above if the TiffLibrary is
+ * compiled with the new interface with Rational2Double or still uses the old definitions,
+ * by setting blnIsRational2Double above.
+ *
+ */
+
+
+/*------------
+ * This version writes the GPS and EXIF tags correctly, without additional main-IFD and parameters!
+ * In contrary, custom_dir.c does write additional main-IFD and parameters to file.
+ -------------*/
+
+
+#define FOR_AUTO_TESTING
+#ifdef FOR_AUTO_TESTING
+/* Only for automake and CMake infrastructure the test should:
+ a.) delete any written testfiles when test passed (otherwise autotest will fail)
+ b.) goto failure, if any failure is detected, which is not necessary when test is initiated manually for debugging
+*/
+#define GOTOFAILURE goto failure;
+#define GOTOFAILURE_GPS goto failure;
+#define GOTOFAILURE_ALL_EXIF goto failure;
+#else
+#define GOTOFAILURE
+#define GOTOFAILURE_GPS
+#define GOTOFAILURE_ALL_EXIF
+#endif
+
+
+#ifdef _MSC_VER
+#pragma warning( disable : 4101)
+#endif
+
+#include "tif_config.h"
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include <errno.h>
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include "tiffio.h"
+#include "tiffiop.h"
+#include "tif_dir.h"
+#include "tifftest.h"
+
+
+
+int write_test_tiff(TIFF *tif, const char *filenameRead);
+
+static const char filename[] = "custom_dir_EXIF_231.tif";
+static const char filenameBigTiff[] = "custom_dir_EXIF_231_Big.tif";
+
+#define SPP 3 /* Samples per pixel */
+const uint16 width = 1;
+const uint16 length = 1;
+const uint16 bps = 8;
+const uint16 photometric = PHOTOMETRIC_RGB;
+const uint16 rows_per_strip = 1;
+const uint16 planarconfig = PLANARCONFIG_CONTIG;
+
+
+int
+main()
+{
+ TIFF *tif;
+ int ret, ret1, ret2;
+
+ fprintf(stderr, "==== Test automatically if all EXIF and GPS tags are written/read correctly. ====\n");
+ /* --- Test with Classic-TIFF ---*/
+ /* delete file, if exists */
+ ret = unlink(filename);
+ if (ret != 0 && errno != ENOENT) {
+ fprintf(stderr, "Can't delete test TIFF file %s.\n", filename);
+ }
+
+ /* We write the main directory as a simple image. */
+ tif = TIFFOpen(filename, "w+");
+ if (!tif) {
+ fprintf(stderr, "Can't create test TIFF file %s.\n", filename);
+ return 1;
+ }
+ fprintf(stderr, "-------- Test with ClassicTIFF started ----------\n");
+ ret1 = write_test_tiff(tif, filename);
+
+ if (ret1 > 0) return(ret1);
+
+ /*--- Test with BIG-TIFF ---*/
+ /* delete file, if exists */
+ ret = unlink(filenameBigTiff);
+ if (ret != 0 && errno != ENOENT) {
+ fprintf(stderr, "Can't delete test TIFF file %s.\n", filenameBigTiff);
+ }
+
+ tif = TIFFOpen(filenameBigTiff, "w8");
+ if (!tif) {
+ fprintf(stderr, "Can't create test TIFF file %s.\n", filenameBigTiff);
+ return 1;
+ }
+ fprintf(stderr, "\n\n-------- Test with BigTIFF started ----------\n");
+ ret2 = write_test_tiff(tif, filenameBigTiff);
+
+ if (ret2 > 0) return(ret2 + 10); else return(ret2);
+
+} /* main() */
+
+
+
+
+
+
+
+int
+write_test_tiff(TIFF *tif, const char *filenameRead)
+{
+ unsigned char buf[SPP] = { 0, 127, 255 };
+ uint64 dir_offset = 0;
+ uint64 dir_offset_GPS = 0, dir_offset_EXIF = 0;
+ uint64 read_dir_offset = 0;
+ /*-- Additional variables --*/
+ int retCode, retCode2;
+ unsigned char exifVersion[4] = {'0','2','3','1'}; /* EXIF 2.31 version is 4 characters of a string! */
+ unsigned char gpsVersion[4] = {2,2,0,1}; /* GPS Version is 4 numbers! */
+ unsigned char *pGpsVersion;
+ float auxFloat = 0.0f;
+ double auxDouble = 0.0;
+ char auxChar = 0;
+ uint32 auxUint32 = 0;
+ short auxShort=0;
+ long auxLong = 0;
+ void *pVoid;
+ int blnIsRational2Double;
+
+ int i, j;
+ long nTags;
+
+ const TIFFFieldArray* tFieldArray;
+ unsigned long tTag;
+ TIFFDataType tType;
+ short tWriteCount;
+ TIFFSetGetFieldType tSetFieldType;
+ char *tFieldName;
+ const TIFFField *fip;
+
+ char blnFillGPSManually = 1;
+
+#define STRSIZE 1000
+#define N_SIZE 120
+#define VARIABLE_ARRAY_SIZE 6
+
+ /* -- Test data for writing -- */
+ char auxCharArrayW[N_SIZE];
+ short auxShortArrayW[N_SIZE];
+ long auxLongArrayW[N_SIZE];
+ float auxFloatArrayW[N_SIZE];
+ double auxDoubleArrayW[N_SIZE];
+ char auxTextArrayW[N_SIZE][STRSIZE];
+ double auxDoubleArrayGPS1[3] = {1.0/7.0, 61.23456789012345, 62.0};
+ double auxDoubleArrayGPS2[3] = {1.0/19.0, 88.34434, 15.12345678901234567890};
+ double auxDoubleArrayGPSTime[3] = {22.0, 17.0, 15.3456789};
+ double auxDoubleGPSAltitude = 3456.0;
+ double auxDoubleGPSDirection = 63.7;
+ float auxFloatArrayN1[3] = { 1.0f / 7.0f, 61.23456789012345f, 62.3f };
+ float auxFloatArrayN2[3] = { -1.0f / 7.0f, -61.23456789012345f, -62.3f };
+
+ /* -- Variables for reading -- */
+ uint16 count16 = 0;
+ union {
+ long Long;
+ short Short1;
+ short Short2[2];
+ char Char[4];
+ } unionLong;
+ union {
+ double dbl;
+ float flt1;
+ float flt2;
+ } auxDblUnion;
+ void *pVoidArray;
+ char *pAscii;
+ char auxCharArray[2*STRSIZE];
+ short auxShortArray[2*N_SIZE];
+ long auxLongArray[2*N_SIZE];
+ float auxFloatArray[2*N_SIZE];
+ double auxDoubleArray[2*N_SIZE];
+ double dblDiff, dblDiffLimit;
+#define RATIONAL_EPS (1.0/30000.0) /* reduced difference of rational values, approx 3.3e-5 */
+
+ /*-- Fill test data arrays for writing ----------- */
+ for (i=0; i<N_SIZE; i++) {
+ sprintf(auxTextArrayW[i],"N%d-String-%d_tttttttttttttttttttttttttttttx", i, i);
+ }
+ for (i=0; i<N_SIZE; i++) {
+ auxCharArrayW[i] = (char)(i+1);
+ }
+ for (i=0; i<N_SIZE; i++) {
+ auxShortArrayW[i] = (short)(i+1)*7;
+ }
+ for (i=0; i<N_SIZE; i++) {
+ auxLongArrayW[i] = (i+1)*133;
+ }
+ for (i=0; i<N_SIZE; i++) {
+ auxFloatArrayW[i] = (float)((i+1)*133)/3.3f;
+ }
+ for (i=0; i<N_SIZE; i++) {
+ auxDoubleArrayW[i] = (double)((i+1)*3689)/4.5697;
+ }
+
+ /*-- Setup standard tags of a simple tiff file --*/
+ if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) {
+ fprintf (stderr, "Can't set ImageWidth tag.\n");
+ goto failure;
+ }
+ if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) {
+ fprintf (stderr, "Can't set ImageLength tag.\n");
+ goto failure;
+ }
+ if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps)) {
+ fprintf (stderr, "Can't set BitsPerSample tag.\n");
+ goto failure;
+ }
+ if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP)) {
+ fprintf (stderr, "Can't set SamplesPerPixel tag.\n");
+ goto failure;
+ }
+ if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) {
+ fprintf (stderr, "Can't set SamplesPerPixel tag.\n");
+ goto failure;
+ }
+ if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, planarconfig)) {
+ fprintf (stderr, "Can't set PlanarConfiguration tag.\n");
+ goto failure;
+ }
+ if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric)) {
+ fprintf (stderr, "Can't set PhotometricInterpretation tag.\n");
+ goto failure;
+ }
+
+#define ADDITIONAL_TAGS
+#ifdef ADDITIONAL_TAGS
+ /*-- Additional tags to check Rational standard tags, which are also defined as FIELD_CUSTOM */
+
+ /*- TIFFTAG_INKSET is a SHORT parameter (TIFF_SHORT, TIFF_SETGET_UINT16) with field_bit=FIELD_CUSTOM !! -*/
+ if (!TIFFSetField(tif, TIFFTAG_INKSET, 34)) {
+ fprintf(stderr, "Can't set TIFFTAG_INKSET tag.\n");
+ goto failure;
+ }
+
+ /*- TIFFTAG_PIXAR_FOVCOT is a FLOAT parameter ( TIFF_FLOAT, TIFF_SETGET_FLOAT) with field_bit=FIELD_CUSTOM !! -*/
+ /* - can be written with Double but has to be read with float parameter */
+#define PIXAR_FOVCOT_VAL 5.123456789123456789
+ auxFloat = (float)PIXAR_FOVCOT_VAL;
+ auxDouble = (double)PIXAR_FOVCOT_VAL;
+ if (!TIFFSetField(tif, TIFFTAG_PIXAR_FOVCOT, auxDouble)) {
+ fprintf(stderr, "Can't set TIFFTAG_PIXAR_FOVCOT tag.\n");
+ goto failure;
+ }
+ /*- TIFFTAG_STONITS is a DOUBLE parameter (TIFF_DOUBLE, TIFF_SETGET_DOUBLE) with field_bit=FIELD_CUSTOM!
+ * Only TIFFTAG_STONITS is a TIFF_DOUBLE, which has to be read as DOUBLE!!
+ */
+#define STONITS_VAL 6.123456789123456789
+ auxDouble = STONITS_VAL;
+ auxFloat = (float)auxDouble;
+ if (!TIFFSetField(tif, TIFFTAG_STONITS, auxDouble)) {
+ fprintf(stderr, "Can't set TIFFTAG_STONITS tag.\n");
+ goto failure;
+ }
+
+ /*- TIFFTAG_YCBCRPOSITIONING is a SHORT parameter */
+ auxLong = auxShort = 5;
+ if (!TIFFSetField(tif, TIFFTAG_YCBCRPOSITIONING, auxLong )) {
+ fprintf (stderr, "Can't set TIFFTAG_YCBCRPOSITIONING tag.\n");
+ goto failure;
+ }
+
+ /* - TIFFTAG_BESTQUALITYSCALE is a Rational parameter, FIELD_CUSTOM and TIFF_SETGET_DOUBLE */
+ /* With Rational2Double upgrade tag is redefined to TIFF_SETGET_FLOAT, but can be still written with double. */
+#define BESTQUALITYSCALE_VAL 15.3
+ auxDouble = BESTQUALITYSCALE_VAL;
+ if (!TIFFSetField(tif, TIFFTAG_BESTQUALITYSCALE, auxDouble )) {
+ fprintf (stderr, "Can't set TIFFTAG_BESTQUALITYSCALE tag.\n");
+ goto failure;
+ }
+
+ /* - TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT */
+ if (!TIFFSetField(tif, TIFFTAG_BASELINENOISE, auxDouble)) {
+ fprintf(stderr, "Can't set TIFFTAG_BASELINENOISE tag.\n");
+ goto failure;
+ }
+
+
+ /*--- For static or variable ARRAYs the case is different ---*/
+/*- Variable Array: TIFFTAG_DECODE is a SRATIONAL parameter TIFF_SETGET_C16_FLOAT type FIELD_CUSTOM with passcount=1 and variable length of array. */
+ if (!TIFFSetField(tif, TIFFTAG_DECODE, 3, auxFloatArrayN2)) {
+ fprintf(stderr, "Can't set TIFFTAG_DECODE tag.\n");
+ goto failure;
+ }
+
+ /*- Variable Array: TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT */
+ if (!TIFFSetField(tif, TIFFTAG_BLACKLEVEL, 3, auxFloatArrayN1)) {
+ fprintf(stderr, "Can't set TIFFTAG_BLACKLEVEL tag.\n");
+ goto failure;
+ }
+
+ /*- Fixed Array: TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT */
+ if (!TIFFSetField(tif, TIFFTAG_DEFAULTCROPSIZE, &auxFloatArrayW[0])) {
+ fprintf(stderr, "Can't set TIFFTAG_DEFAULTCROPSIZE tag.\n");
+ goto failure;
+ }
+#endif /* -- ADDITIONAL_TAGS -- */
+
+/*================== Rational2Double Interface Check =====================*/
+ /*-- Check, if the TiffLibrary is compiled with the new interface with Rational2Double or still uses the old definitions.
+ For that, TIFF_RATIONAL tags with FIELD_CUSTOM are changed from TIFF_SETGET_DOUBLE to TIFF_SETGET_FLOAT for the
+ new interface in order to prevent the old reading behaviour.
+ Tags to check: TIFFTAG_BESTQUALITYSCALE, TIFFTAG_BASELINENOISE, TIFFTAG_BASELINESHARPNESS
+ */
+ fip = TIFFFindField(tif, TIFFTAG_BESTQUALITYSCALE, TIFF_ANY);
+ tSetFieldType = fip->set_field_type;
+ if (tSetFieldType == TIFF_SETGET_DOUBLE) {
+ blnIsRational2Double = FALSE;
+ } else {
+ blnIsRational2Double = TRUE;
+ fprintf(stderr, "-- Rational2Double from TIFF tag detected --\n");
+ }
+
+/*================== Write GPS and EXIF tags =====================*/
+
+ /*-- Set dummy EXIF/GPS tag in original tiff-structure in order to reserve space for final dir_offset value, */
+ /* which is properly written at the end. */
+ dir_offset = 0; /* Zero, in case no Custom-IFD is written */
+
+#define WRITE_GPS_TAGS
+#ifdef WRITE_GPS_TAGS
+ if (!TIFFSetField(tif, TIFFTAG_GPSIFD, dir_offset )) {
+ fprintf (stderr, "Can't write TIFFTAG_GPSIFD\n" );
+ }
+#endif
+
+ /*------- And also do the same for the EXIF IFD tag here, because we have to save the main directory next ------*/
+ /*-- Set dummy EXIF/GPS tag in original tiff-structure in order to reserve space for final dir_offset value,
+ * which is properly written at the end.
+ */
+#define WRITE_EXIF_TAGS
+#ifdef WRITE_EXIF_TAGS
+ if (!TIFFSetField(tif, TIFFTAG_EXIFIFD, dir_offset )) {
+ fprintf (stderr, "Can't write TIFFTAG_EXIFIFD\n" );
+ }
+#endif
+
+#ifndef WRITEPIXELLAST
+ /*-- Write dummy pixel data. --*/
+ if (TIFFWriteScanline(tif, buf, 0, 0) < 0) {
+ fprintf (stderr, "Can't write image data.\n");
+ goto failure;
+ }
+#endif
+
+
+#ifdef WRITE_GPS_TAGS
+#define READ_GPS_TAGS
+ /*================== Write GPS tags =====================*/
+
+ /*-- Save current tiff-directory to file before directory is changed. Otherwise it will be lost! */
+ /* The tif-structure is overwritten/ freshly initialized by any "CreateDirectory" */
+ /*retCode = TIFFCheckpointDirectory(tif);*/ /* does not cleanup Tiff-Structure */
+ retCode = TIFFWriteDirectory(tif); /* cleanup Tiff-structure */
+
+ /*-- Now create a GPS directory. */
+ if (TIFFCreateGPSDirectory(tif) != 0) {
+ fprintf (stderr, "TIFFCreateGPSDirectory() failed.\n" );
+ goto failure;
+ }
+
+ if (!TIFFSetField( tif, GPSTAG_VERSIONID, gpsVersion)) {
+ fprintf (stderr, "Can't write GPSTAG_VERSIONID\n" );
+ goto failure;
+ }
+
+ if (blnFillGPSManually) {
+ /*================= Write manually valid data to the GPS fields ==============*/
+ if (!TIFFSetField( tif, GPSTAG_LATITUDEREF, "N\0")) {
+ fprintf (stderr, "Can't write GPSTAG_LATITUDEREF\n" );
+ goto failure;
+ }
+ /*-- Unfortunately, Rational values are defined as SETGET_DOUBLE but are internally always stored as float.
+ * Single Rational values do not matter for writing, because TIFFSetField() uses va_arg() which performs "variables promotion" from type float to type double!
+ * However, for reading of Rational values ONLY float-variables are allowed - in contrary to the SETGET_DOUBLE specification at tiffFields[] in tif_dirinfo.c.
+ */
+ /*-- ATTENTION: After the upgrade with Rational2Double, the GPSTAG values are defined as double precision
+ * and need to be written and also read in double precision!
+ * In order to maintain this code for both cases, it is checked above if the TiffLibrary is
+ * compiled with the new interface with Rational2Double or still uses the old definitions,
+ * by setting blnIsRational2Double above.
+ */
+ if (blnIsRational2Double) {
+ fprintf(stderr, "-- GPS tags are written using Rational2Double --\n");
+ } else {
+ fprintf(stderr, "-- GPS tags are written using standard --\n");
+ }
+ if (!blnIsRational2Double) {
+ for (j = 0; j < 3; j++) auxFloatArray[j] = (float)auxDoubleArrayGPS1[j];
+ if (!TIFFSetField(tif, GPSTAG_LATITUDE, auxFloatArray)) {
+ fprintf(stderr, "Can't write GPSTAG_LATITUDE\n");
+ goto failure;
+ }
+ } else {
+ /* Rational2Double interface for GPSTAG */
+ if (!TIFFSetField(tif, GPSTAG_LATITUDE, auxDoubleArrayGPS1)) {
+ fprintf(stderr, "Can't write GPSTAG_LATITUDE\n");
+ goto failure;
+ }
+ }
+ if (!TIFFSetField( tif, GPSTAG_LONGITUDEREF, "W\0")) {
+ fprintf (stderr, "Can't write GPSTAG_LONGITUDEREF\n" );
+ goto failure;
+ }
+ if (!blnIsRational2Double) {
+ for (j=0; j<3; j++) auxFloatArray[j] = (float)auxDoubleArrayGPS2[j];
+ if (!TIFFSetField( tif, GPSTAG_LONGITUDE, auxFloatArray)) {
+ fprintf (stderr, "Can't write GPSTAG_LONGITUDE\n" );
+ goto failure;
+ }
+ } else {
+ /* Rational2Double interface for GPSTAG */
+ if (!TIFFSetField(tif, GPSTAG_LONGITUDE, auxDoubleArrayGPS2)) {
+ fprintf(stderr, "Can't write GPSTAG_LATITUDE\n");
+ goto failure;
+ }
+ }
+ /*-- AltitudeRef: default is above sea level!! */
+ if (!TIFFSetField( tif, GPSTAG_ALTITUDEREF, 0)) {
+ fprintf (stderr, "Can't write GPSTAG_ALTITUDEREF\n" );
+ goto failure;
+ }
+ if (!TIFFSetField( tif, GPSTAG_ALTITUDE, auxDoubleGPSAltitude)) {
+ fprintf (stderr, "Can't write GPSTAG_ALTITUDE\n" );
+ goto failure;
+ }
+ /*-- TimeStamp is only hh:mm:ss. See also DateTime string */
+ if (!TIFFSetField( tif, GPSTAG_TIMESTAMP, auxDoubleArrayGPSTime)) {
+ fprintf (stderr, "Can't write GPSTAG_TIMESTAMP\n" );
+ goto failure;
+ }
+ if (!TIFFSetField( tif, GPSTAG_DATESTAMP, "2012:11:04")) {
+ fprintf (stderr, "Can't write GPSTAG_DATESTAMP\n" );
+ goto failure;
+ }
+
+ if (!TIFFSetField( tif, GPSTAG_IMGDIRECTIONREF, "T\0")) {
+ fprintf (stderr, "Can't write GPSTAG_IMGDIRECTIONREF\n" );
+ goto failure;
+ }
+ if (!TIFFSetField( tif, GPSTAG_IMGDIRECTION, auxDoubleGPSDirection)) {
+ fprintf (stderr, "Can't write GPSTAG_IMGDIRECTION\n" );
+ goto failure;
+ }
+
+ /*-- Type TIFF_UNDEFINED */
+ if (!TIFFSetField( tif, GPSTAG_PROCESSINGMETHOD, 3, &auxCharArrayW[10])) {
+ fprintf (stderr, "Can't write GPSTAG_PROCESSINGMETHOD\n" );
+ goto failure;
+ }
+ if (!TIFFSetField( tif, GPSTAG_AREAINFORMATION, 4, &auxCharArrayW[20])) {
+ fprintf (stderr, "Can't write GPSTAG_AREAINFORMATION\n" );
+ goto failure;
+ }
+
+ /*-- PSTAG_DIFFERENTIAL , 1, 1, TIFF_SHORT , 0, TIFF_SETGET_UINT16 */
+ if (!TIFFSetField( tif, GPSTAG_DIFFERENTIAL, auxShortArrayW[5])) {
+ fprintf (stderr, "Can't write GPSTAG_DIFFERENTIAL\n" );
+ goto failure;
+ }
+
+ /* GPSTAG_GPSHPOSITIONINGERROR , 1, 1, TIFF_RATIONAL , 0, TIFF_SETGET_DOUBLE but here written in float-precision */
+#define GPSHPOSITIONINGERROR_VAL 0.369
+ auxFloat = (float)GPSHPOSITIONINGERROR_VAL;
+ if (!TIFFSetField( tif, GPSTAG_GPSHPOSITIONINGERROR, auxFloat)) {
+ fprintf (stderr, "Can't write GPSTAG_GPSHPOSITIONINGERROR\n" );
+ goto failure;
+ }
+
+ } else {
+ /*================= Write arbitrary data to the GPS fields ==============*/
+
+ /*-- Get array, where GPS tag fields are defined --*/
+ tFieldArray = _TIFFGetGpsFields();
+ nTags = tFieldArray->count;
+
+ /*-- TODO: fill in the for / switch part of EXIF writing, when finished and tested!! */
+
+ } /*-- if (blnFillGPSManually) --*/
+
+
+
+
+ /*-- GPS - write custom directory GPS into file...---*/
+ /* (Get back the offset of GPS directory) */
+ if (!TIFFWriteCustomDirectory( tif, &dir_offset_GPS )) {
+ fprintf (stderr, "TIFFWriteCustomDirectory() with GPS failed.\n");
+ goto failure;
+ }
+
+ /*--- CheckpointDirectory at this place generates a second Main-IFD!!! */
+ /* retCode = TIFFCheckpointDirectory(tif); */
+
+ /*-- Set / reload previously saved main directory from file ---*/
+ if (!TIFFSetDirectory(tif, 0)) {
+ fprintf (stderr, "TIFFSetDirectory() within GPS failed.\n");
+ goto failure;
+ }
+
+ /*-- Write GPS tag reference / offset into GPSIFD tag in main directory --*/
+ if (!TIFFSetField(tif, TIFFTAG_GPSIFD, dir_offset_GPS )) {
+ fprintf (stderr, "Can't write TIFFTAG_GPSIFD\n");
+ goto failure;
+ }
+
+ /*=============== END writing GPS tags ==========================*/
+#endif /*-- WRITE_GPS_TAGS --*/
+
+
+/*================== Write EXIF 2.31 tags =====================*/
+
+ /*-- Set dummy EXIF/GPS tag in original tiff-structure in order to reserve space for final dir_offset value, */
+ /* which is properly written at the end.*/
+ /*- We did this already above together with the GPS IFD-tag. Otherwise we would do this here !! --------*/
+ /* if (!TIFFSetField(tif, TIFFTAG_EXIFIFD, dir_offset )) {
+ fprintf (stderr, "Can't write TIFFTAG_EXIFIFD\n" );
+ }
+ */
+
+#ifdef WRITE_EXIF_TAGS
+#define READ_EXIF_TAGS
+ /*-- Save current tiff-directory to file before directory is changed. Otherwise it will be lost!
+ * The tif-structure is overwritten/ freshly initialized by any "CreateDirectory"
+ */
+
+ /*----- What is needed here ??? ----
+ * In custom_dir.c only TIFFFreeDirectory( tif ); is used to set fields of another Sub-Directory
+ * TIFFFreeDirectory(tif); *-- Release storage associated with a directory, especially custom-fields.
+ *-- Using only TIFFFreeDirectory() here leads to an error!!
+ *-- Using here TIFFCheckpointDirectory() leads to an additional Main-IFD ??
+ */
+ /*retCode = TIFFCheckpointDirectory(tif);*/ /* does not cleanup Tiff-Structure */
+ retCode = TIFFWriteDirectory(tif); /* cleanup Tiff-structure */
+
+ /*-- Now create an EXIF directory. */
+ if (TIFFCreateEXIFDirectory(tif) != 0) {
+ fprintf (stderr, "TIFFCreateEXIFDirectory() failed.\n" );
+ goto failure;
+ }
+
+#define WRITE_ALL_EXIF_TAGS
+#ifdef WRITE_ALL_EXIF_TAGS
+#define READ_ALL_EXIF_TAGS
+ /*================= EXIF: Write arbitrary data to the EXIF fields ==============*/
+ /*-- Get array, where EXIF tag fields are defined
+ * EXIF tags are written automatically with the defined precision according to its tSetFieldType using the code below --*/
+ tFieldArray = _TIFFGetExifFields();
+ nTags = tFieldArray->count;
+
+ for (i=0; i<nTags; i++) {
+ tTag = tFieldArray->fields[i].field_tag;
+ tType = tFieldArray->fields[i].field_type; /* e.g. TIFF_RATIONAL */
+ tWriteCount = tFieldArray->fields[i].field_writecount;
+ tSetFieldType = tFieldArray->fields[i].set_field_type; /* e.g. TIFF_SETGET_C0_FLOAT */
+ tFieldName = tFieldArray->fields[i].field_name;
+ pVoid = NULL;
+
+ /*-- dependent on set_field_type write value --*/
+ switch (tSetFieldType)
+ {
+ case TIFF_SETGET_ASCII:
+ /* Either the stringlength is defined as a fixed length in .field_writecount or a NULL-terminated string is used. */
+ /* Shorter strings than in auxTextArraxW need a NULL-termination. Therefore copy the string. */
+ if (tWriteCount > 0) auxLong = tWriteCount-1; else auxLong = (long)strlen(auxTextArrayW[i])-1;
+ strncpy(auxCharArray, auxTextArrayW[i], auxLong);
+ auxCharArray[auxLong] = 0;
+ if (!TIFFSetField( tif, tTag, auxCharArray)) {
+ fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
+ goto failure;
+ }
+ break;
+ case TIFF_SETGET_UINT8:
+ case TIFF_SETGET_UINT16:
+ case TIFF_SETGET_UINT32:
+ case TIFF_SETGET_IFD8:
+ case TIFF_SETGET_INT:
+ /*-- All those can be written with char, short or long parameter. Only value range should be in line. */
+ if (!TIFFSetField( tif, tTag, auxLongArrayW[i])) {
+ fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
+ goto failure;
+ }
+ break;
+ case TIFF_SETGET_SINT8:
+ case TIFF_SETGET_SINT16:
+ case TIFF_SETGET_SINT32:
+ /*-- All those can be written with char, short or long parameter. Only value range should be in line. */
+ if (!TIFFSetField( tif, tTag, -1.0*auxLongArrayW[i])) {
+ fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
+ goto failure;
+ }
+ break;
+ case TIFF_SETGET_FLOAT:
+ case TIFF_SETGET_DOUBLE:
+ if (tWriteCount == 1) {
+ /*-- All single values can be written with float or double parameter. Only value range should be in line. */
+ if (!TIFFSetField( tif, tTag, auxDoubleArrayW[i])) {
+ fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
+ goto failure;
+ }
+ } else {
+ fprintf (stderr, "WriteCount for .set_field_type %d should be 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name);
+ }
+ break;
+ case TIFF_SETGET_C0_FLOAT:
+ case TIFF_SETGET_C0_DOUBLE:
+ case TIFF_SETGET_C16_FLOAT:
+ case TIFF_SETGET_C16_DOUBLE:
+ case TIFF_SETGET_C32_FLOAT:
+ case TIFF_SETGET_C32_DOUBLE:
+ /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */
+ /*-- Check, if it is a single parameter, a fixed array or a variable array */
+ if (tWriteCount == 1) {
+ fprintf (stderr, "WriteCount for .set_field_type %d should be -1 or greater than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name);
+ } else {
+ /*-- Either fix or variable array --*/
+ /* For arrays, distinguishing between float or double is essential, even for writing */
+ if (tSetFieldType == TIFF_SETGET_C0_FLOAT || tSetFieldType == TIFF_SETGET_C16_FLOAT || tSetFieldType == TIFF_SETGET_C32_FLOAT)
+ pVoid = &auxFloatArrayW[i]; else pVoid = &auxDoubleArrayW[i];
+ /* Now decide between fixed or variable array */
+ if (tWriteCount > 1) {
+ /* fixed array with needed arraysize defined in .field_writecount */
+ if (!TIFFSetField( tif, tTag, pVoid)) {
+ fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
+ goto failure;
+ }
+ } else {
+ /* special treatment of variable array */
+ /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */
+ if (!TIFFSetField( tif, tTag, VARIABLE_ARRAY_SIZE, pVoid)) {
+ fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
+ goto failure;
+ }
+ }
+ }
+ break;
+ case TIFF_SETGET_C0_UINT8:
+ case TIFF_SETGET_C0_SINT8:
+ case TIFF_SETGET_C16_UINT8:
+ case TIFF_SETGET_C16_SINT8:
+ case TIFF_SETGET_C32_UINT8:
+ case TIFF_SETGET_C32_SINT8:
+ /* For arrays, distinguishing between float or double is essential, even for writing */
+ pVoid = &auxCharArrayW[i];
+ case TIFF_SETGET_C0_UINT16:
+ case TIFF_SETGET_C0_SINT16:
+ case TIFF_SETGET_C16_UINT16:
+ case TIFF_SETGET_C16_SINT16:
+ case TIFF_SETGET_C32_UINT16:
+ case TIFF_SETGET_C32_SINT16:
+ if (pVoid == NULL) pVoid = &auxShortArrayW[i];
+ case TIFF_SETGET_C0_UINT32:
+ case TIFF_SETGET_C0_SINT32:
+ case TIFF_SETGET_C16_UINT32:
+ case TIFF_SETGET_C16_SINT32:
+ case TIFF_SETGET_C32_UINT32:
+ case TIFF_SETGET_C32_SINT32:
+ if (pVoid == NULL) pVoid = &auxLongArrayW[i];
+ /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */
+ /*-- Check, if it is a single parameter, a fixed array or a variable array */
+ if (tWriteCount == 1) {
+ fprintf (stderr, "WriteCount for .set_field_type %d should be -1 or greater than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name);
+ } else {
+ /*-- Either fix or variable array --*/
+ /* Now decide between fixed or variable array */
+ if (tWriteCount > 1) {
+ /* fixed array with needed arraysize defined in .field_writecount */
+ if (!TIFFSetField( tif, tTag, pVoid)) {
+ fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
+ goto failure;
+ }
+ } else {
+ /* special treatment of variable array */
+ /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */
+ if (!TIFFSetField( tif, tTag, VARIABLE_ARRAY_SIZE, pVoid)) {
+ fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name);
+ goto failure;
+ }
+ }
+ }
+ break;
+ default:
+ fprintf (stderr, "SetFieldType %d not defined within writing switch for %s.\n", tSetFieldType, tFieldName);
+ }; /*-- switch() --*/
+ } /*-- for() --*/
+ /*================= EXIF: END Writing arbitrary data to the EXIF fields END END END ==============*/
+#endif /*-- WRITE_ALL_EXIF_TAGS --*/
+
+ /*--- Set valid EXIF version, which is a 4 byte string --*/
+ if (!TIFFSetField( tif, EXIFTAG_EXIFVERSION, exifVersion)) {
+ fprintf (stderr, "Can't write EXIFTAG_EXIFVERSION\n" );
+ goto failure;
+ }
+
+
+ /*-- EXIF - write custom directory EXIF into file...---*/
+ /* (Get back the offset of EXIF directory) */
+ if (!TIFFWriteCustomDirectory( tif, &dir_offset_EXIF )) {
+ fprintf (stderr, "TIFFWriteCustomDirectory() with EXIF failed.\n");
+ goto failure;
+ }
+
+ /*-- Go back to the first (main) directory, and set correct value of the EXIFIFD pointer. */
+ /* (directory is reloaded from file!) */
+ TIFFSetDirectory(tif, 0);
+ TIFFSetField(tif, TIFFTAG_EXIFIFD, dir_offset_EXIF );
+#endif /*-- WRITE_EXIF_TAGS --*/
+
+#ifdef WRITEPIXELLAST
+ /*-- Write dummy pixel data. --*/
+ if (TIFFWriteScanline(tif, buf, 0, 0) < 0) {
+ fprintf (stderr, "Can't write image data.\n");
+ goto failure;
+ }
+#endif
+ /*-- Write directory to file --*/
+ /* Always WriteDirectory before using/creating another directory. */
+ /* Not necessary before TIFFClose(), however, TIFFClose() uses TIFFReWriteDirectory(), which forces directory to be written at another location. */
+ retCode = TIFFWriteDirectory(tif);
+
+ /*-- Write File to disk and close file --*/
+ /* TIFFClose() uses TIFFReWriteDirectory(), which forces directory to be written at another location. */
+ /* Therefore, better use TIFFWriteDirectory() before. */
+ TIFFClose(tif);
+
+ fprintf (stderr, "-------- Continue Test ---------- reading ...\n");
+
+/*========================= READING ============= READING ========================================*/
+ /* Ok, now test whether we can read written values correctly. */
+ tif = TIFFOpen(filenameRead, "r");
+
+
+ /*-- Read some parameters out of the main directory --*/
+
+ /*-- IMAGEWIDTH and -LENGTH are defined as TIFF_SETGET_UINT32 */
+ retCode = TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &auxUint32 );
+ if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_IMAGEWIDTH"); }
+ if (auxUint32 != width) {
+ fprintf (stderr, "Read value of IMAGEWIDTH %d differs from set value %d\n", auxUint32, width);
+ }
+ retCode = TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &auxUint32 );
+ if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_IMAGELENGTH"); }
+ if (auxUint32 != width) {
+ fprintf (stderr, "Read value of TIFFTAG_IMAGELENGTH %d differs from set value %d\n", auxUint32, length);
+ }
+
+#ifdef ADDITIONAL_TAGS
+ /*- TIFFTAG_PIXAR_FOVCOT is a FLOAT parameter of type FIELD_CUSTOM !! */
+ retCode = TIFFGetField(tif, TIFFTAG_PIXAR_FOVCOT, &auxFloat );
+ if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_PIXAR_FOVCOT"); }
+ if (auxFloat != (float)PIXAR_FOVCOT_VAL) {
+ fprintf (stderr, "Read value of TIFFTAG_PIXAR_FOVCOT %f differs from set value %f\n", auxFloat, PIXAR_FOVCOT_VAL);
+ }
+
+ /* - TIFFTAG_BESTQUALITYSCALE is a Rational parameter, FIELD_CUSTOM and TIFF_SETGET_FLOAT */
+ retCode = TIFFGetField(tif, TIFFTAG_BESTQUALITYSCALE, &auxFloat );
+ if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_BESTQUALITYSCALE"); }
+ if (auxFloat != (float)BESTQUALITYSCALE_VAL) {
+ fprintf (stderr, "Read value of TIFFTAG_BESTQUALITYSCALE %f differs from set value %f\n", auxFloat, BESTQUALITYSCALE_VAL);
+ }
+
+ /* - TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT */
+ retCode = TIFFGetField(tif, TIFFTAG_BASELINENOISE, &auxDblUnion.dbl);
+ if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_BASELINENOISE"); }
+ if (auxDblUnion.flt1 != (float)BESTQUALITYSCALE_VAL) {
+ fprintf(stderr, "Read float value of TIFFTAG_BASELINENOISE %f differs from set value %f\n", auxDblUnion.flt1, BESTQUALITYSCALE_VAL);
+ }
+
+
+ /*- Variable Array: TIFFTAG_DECODE is a SRATIONAL parameter TIFF_SETGET_C16_FLOAT type FIELD_CUSTOM with passcount=1 and variable length of array. */
+ retCode = TIFFGetField(tif, TIFFTAG_DECODE, &count16, &pVoidArray );
+ if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_DECODE"); }
+ /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, contents needs to be saved. */
+ memcpy(&auxFloatArray, pVoidArray,(count16 * sizeof(auxFloatArray[0])));
+ for (i=0; i<count16; i++) {
+ dblDiffLimit = RATIONAL_EPS*auxFloatArrayN2[i];
+ dblDiff = auxFloatArray[i] - auxFloatArrayN2[i];
+ if (fabs(dblDiff) > fabs(dblDiffLimit)) {
+ fprintf (stderr, "Read value %d of TIFFTAG_DECODE Array %f differs from set value %f\n", i, auxFloatArray[i], auxFloatArrayN2[i]);
+ }
+ }
+
+ retCode = TIFFGetField(tif, TIFFTAG_BLACKLEVEL, &count16, &pVoidArray);
+ if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_BLACKLEVEL"); }
+ /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, contents needs to be saved. */
+ memcpy(&auxFloatArray, pVoidArray, (count16 * sizeof(auxFloatArray[0])));
+ for (i = 0; i<count16; i++) {
+ dblDiffLimit = RATIONAL_EPS*auxFloatArrayN1[i];
+ dblDiff = auxFloatArray[i] - auxFloatArrayN1[i];
+ if (fabs(dblDiff) > fabs(dblDiffLimit)) {
+ fprintf(stderr, "Read value %d of TIFFTAG_BLACKLEVEL Array %f differs from set value %f\n", i, auxFloatArray[i], auxFloatArrayN1[i]);
+ }
+ }
+
+ /*- Fixed Array: TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT */
+ retCode = TIFFGetField(tif, TIFFTAG_DEFAULTCROPSIZE, &pVoidArray);
+ if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_DEFAULTCROPSIZE"); }
+ /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, contents needs to be saved. */
+ memcpy(&auxFloatArray, pVoidArray, (2 * sizeof(auxFloatArray[0])));
+ for (i = 0; i < 2; i++) {
+ dblDiffLimit = RATIONAL_EPS * auxFloatArrayW[i];
+ dblDiff = auxFloatArray[i] - auxFloatArrayW[i];
+ if (fabs(dblDiff) > fabs(dblDiffLimit)) {
+ fprintf(stderr, "Read value %d of TIFFTAG_DEFAULTCROPSIZE Array %f differs from set value %f\n", i, auxFloatArray[i], auxFloatArrayW[i]);
+ }
+ }
+
+#endif /*-- ADDITIONAL_TAGS --*/
+
+
+#ifdef READ_GPS_TAGS
+/*================== Reading GPS tags =====================*/
+ /*-- First get offset to GPS-directory and set it active (this will destroy previously main directory fields in memory!) */
+ retCode = TIFFGetField(tif, TIFFTAG_GPSIFD, &read_dir_offset );
+ if (!retCode) {fprintf(stderr, "Can't read %s\n", "TIFFTAG_GPSIFD"); }
+ retCode = TIFFReadGPSDirectory(tif, read_dir_offset);
+ if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFReadGPSDirectory()"); }
+
+ /*-- Now read some parameters from GPS-directory --*/
+
+ /*-- Fixed Array: GPS-Version is a fixed array (of 4 characters) */
+ retCode = TIFFGetField(tif, GPSTAG_VERSIONID, &pGpsVersion);
+ if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_VERSIONID"); }
+ else {
+ memcpy(auxCharArray, pGpsVersion, sizeof(gpsVersion));
+ for (i = 0; i < 4; i++) {
+ if (auxCharArray[i] != pGpsVersion[i]) {
+ fprintf(stderr, "Read value %d of GPSTAG_VERSIONID %d differs from set value %d\n", i, auxCharArray[i], pGpsVersion[i]);
+ }
+ }
+ }
+ /*-- LATITUDEREF is a fixed String of one character plus ending zero. */
+ retCode = TIFFGetField(tif, GPSTAG_LATITUDEREF, &pAscii);
+ if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_LATITUDEREF"); }
+ retCode2 = strncmp("N", pAscii, 1);
+ if (retCode2 != 0) {
+ fprintf (stderr, "Read value %d of GPSTAG_LATITUDEREF %s differs from set value %s\n", i, "N", pAscii);
+ }
+
+ /*-- Fixed Array: Latitude is an array of 3 Rational-values. TIFFGetField() returns a pointer to a temporary float-/double-array. */
+ /*-- ATTENTION: After the upgrade with Rational2Double, the GPSTAG values are defined as double precision
+ * and need to be written and also read in double precision!
+ * In order to maintain this code for both cases, it is checked above if the TiffLibrary is
+ * compiled with the new interface with Rational2Double or still uses the old definitions,
+ * by setting blnIsRational2Double above.
+ */
+ if (blnIsRational2Double) {
+ fprintf(stderr, "-- GPS tags are read using Rational2Double --\n");
+ } else {
+ fprintf(stderr, "-- GPS tags are read using standard --\n");
+ }
+ retCode = TIFFGetField(tif, GPSTAG_LATITUDE, &pVoidArray);
+ if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_LATITUDE"); }
+ if (!blnIsRational2Double) {
+ /* Reset arrays for debugging purpose first */
+ memset(auxFloatArray, 0, sizeof(auxFloatArray));
+ memcpy(auxFloatArray, pVoidArray, 3*sizeof(float));
+ /* for comparison copy to doubleArray */
+ for (i=0; i<3; i++) auxDoubleArray[i] = (double)auxFloatArray[i];
+ } else {
+ /* Rational2Double interface for GPSTAG reads double array */
+ memset(auxDoubleArray, 0, sizeof(auxDoubleArray));
+ memcpy(auxDoubleArray, pVoidArray, 3 * sizeof(double));
+ }
+ for (i=0; i<3; i++) {
+ dblDiffLimit = RATIONAL_EPS*auxDoubleArrayGPS1[i];
+ dblDiff = auxDoubleArray[i] - auxDoubleArrayGPS1[i];
+ if (fabs(dblDiff) > fabs(dblDiffLimit)) {
+ fprintf (stderr, "Read value %d of GPSTAG_LATITUDE %f differs from set value %f\n", i, auxDoubleArray[i], auxDoubleArrayGPS1[i]);
+ }
+ }
+
+ /*-- LONGITUDEREF is a fixed String of one character plus ending zero. */
+ retCode = TIFFGetField(tif, GPSTAG_LONGITUDEREF, &pAscii);
+ if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_LONGITUDEREF"); }
+ retCode2 = strncmp("W", pAscii, 1);
+ if (retCode2 != 0) {
+ fprintf(stderr, "Read value %d of GPSTAG_LONGITUDEREF %s differs from set value %s\n", i, "W", pAscii);
+ }
+
+ retCode = TIFFGetField(tif, GPSTAG_LONGITUDE, &pVoidArray);
+ if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_LONGITUDE"); }
+ if (!blnIsRational2Double) {
+ /* Reset arrays for debugging purpose first */
+ memset(auxFloatArray, 0, sizeof(auxFloatArray));
+ memcpy(auxFloatArray, pVoidArray, 3 * sizeof(float));
+ /* for comparison copy to doubleArray */
+ for (i = 0; i < 3; i++) auxDoubleArray[i] = (double)auxFloatArray[i];
+ } else {
+ /* Rational2Double interface for GPSTAG reads double array */
+ memset(auxDoubleArray, 0, sizeof(auxDoubleArray));
+ memcpy(auxDoubleArray, pVoidArray, 3 * sizeof(double));
+ }
+ for (i = 0; i < 3; i++) {
+ dblDiffLimit = RATIONAL_EPS * auxDoubleArrayGPS2[i];
+ dblDiff = auxDoubleArray[i] - auxDoubleArrayGPS2[i];
+ if (fabs(dblDiff) > fabs(dblDiffLimit)) {
+ fprintf(stderr, "Read value %d of GPSTAG_LONGITUDE %f differs from set value %f\n", i, auxDoubleArray[i], auxDoubleArrayGPS2[i]);
+ }
+ }
+
+ /* TIFF_RATIONAL, TIFF_SETGET_DOUBLE */
+ if (!TIFFGetField(tif, GPSTAG_ALTITUDE, &auxDblUnion.dbl)) {
+ fprintf(stderr, "Can't read GPSTAG_ALTITUDE\n");
+ GOTOFAILURE_GPS
+ }
+ if (blnIsRational2Double) {
+ /* New interface allows also double precision for TIFF_RATIONAL */
+ auxDouble = auxDblUnion.dbl;
+ } else {
+ /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE always as FLOAT */
+ auxDouble = (double)auxDblUnion.flt1;
+ }
+ /* compare read values with written ones */
+ dblDiffLimit = RATIONAL_EPS * auxDoubleGPSAltitude;
+ dblDiff = auxDouble - auxDoubleGPSAltitude;
+ if (fabs(dblDiff) > fabs(dblDiffLimit)) {
+ fprintf(stderr, "Read value of GPSTAG_ALTITUDE %f differs from set value %f\n", auxDouble, auxDoubleGPSAltitude);
+ GOTOFAILURE_GPS
+ }
+
+ /*-- TimeStamp is only hh:mm:ss. See also DateTime string 3, TIFF_RATIONAL, TIFF_SETGET_C0_DOUBLE */
+ retCode = TIFFGetField(tif, GPSTAG_TIMESTAMP, &pVoidArray);
+ if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_TIMESTAMP"); }
+ if (!blnIsRational2Double) {
+ /* Reset arrays for debugging purpose first */
+ memset(auxFloatArray, 0, sizeof(auxFloatArray));
+ memcpy(auxFloatArray, pVoidArray, 3 * sizeof(float));
+ /* for comparison copy to doubleArray */
+ for (i = 0; i < 3; i++) auxDoubleArray[i] = (double)auxFloatArray[i];
+ } else {
+ /* Rational2Double interface for GPSTAG reads double array */
+ memset(auxDoubleArray, 0, sizeof(auxDoubleArray));
+ memcpy(auxDoubleArray, pVoidArray, 3 * sizeof(double));
+ }
+ for (i = 0; i < 3; i++) {
+ dblDiffLimit = RATIONAL_EPS * auxDoubleArrayGPSTime[i];
+ dblDiff = auxDoubleArray[i] - auxDoubleArrayGPSTime[i];
+ if (fabs(dblDiff) > fabs(dblDiffLimit)) {
+ fprintf(stderr, "Read value %d of GPSTAG_TIMESTAMP %f differs from set value %f\n", i, auxDoubleArray[i], auxDoubleArrayGPS2[i]);
+ GOTOFAILURE_GPS
+ }
+ }
+
+ /* GPSTAG_IMGDIRECTION --- TIFF_RATIONAL, TIFF_SETGET_DOUBLE */
+ if (!TIFFGetField(tif, GPSTAG_IMGDIRECTION, &auxDblUnion.dbl)) {
+ fprintf(stderr, "Can't read GPSTAG_IMGDIRECTION\n");
+ GOTOFAILURE_GPS
+ }
+ if (blnIsRational2Double) {
+ /* New interface allows also double precision for TIFF_RATIONAL */
+ auxDouble = auxDblUnion.dbl;
+ } else {
+ /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE always as FLOAT */
+ auxDouble = (double)auxDblUnion.flt1;
+ }
+ /* compare read values with written ones */
+ dblDiffLimit = RATIONAL_EPS * auxDoubleGPSDirection;
+ dblDiff = auxDouble - auxDoubleGPSDirection;
+ if (fabs(dblDiff) > fabs(dblDiffLimit)) {
+ fprintf(stderr, "Read value of GPSTAG_IMGDIRECTION %f differs from set value %f\n", auxDouble, auxDoubleGPSDirection);
+ GOTOFAILURE_GPS
+ }
+
+ /*-- GPSTAG_DIFFERENTIAL , 1, 1, TIFF_SHORT , 0, TIFF_SETGET_UINT16 */
+ retCode = TIFFGetField(tif, GPSTAG_DIFFERENTIAL, &auxShort);
+ if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_DIFFERENTIAL"); }
+ if (auxShort != auxShortArrayW[5]) {
+ fprintf(stderr, "Read value of GPSTAG_DIFFERENTIAL %d differs from set value %d\n", auxShort, auxShortArrayW[5]);
+ GOTOFAILURE_GPS
+ }
+
+ /*-- GPSHPOSITIONINGERROR - new tag for EXIF 2.31 --*/
+ if (!TIFFGetField(tif, GPSTAG_GPSHPOSITIONINGERROR, &auxDblUnion.dbl)) {
+ fprintf(stderr, "Can't read GPSTAG_GPSHPOSITIONINGERROR\n");
+ GOTOFAILURE_GPS
+ }
+ if (blnIsRational2Double) {
+ /* New interface allows also double precision for TIFF_RATIONAL */
+ auxDouble = auxDblUnion.dbl;
+ } else {
+ /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE always as FLOAT */
+ auxDouble = (double)auxDblUnion.flt1;
+ }
+ /* compare read values with written ones */
+ auxFloat = (float)GPSHPOSITIONINGERROR_VAL;
+ dblDiffLimit = RATIONAL_EPS * auxFloat;
+ dblDiff = auxDouble - auxFloat;
+ if (fabs(dblDiff) > fabs(dblDiffLimit)) {
+ fprintf(stderr, "Read value of GPSTAG_GPSHPOSITIONINGERROR %f differs from set value %f\n", auxDouble, auxFloat);
+ GOTOFAILURE_GPS
+ }
+
+ /*=============== END reading GPS tags ==========================*/
+#endif /*-- READ_GPS_TAGS --*/
+
+
+
+/*================== Reading EXIF 2.31 tags =====================*/
+
+ /*--- Firstly, get EXIF directory offset from main directory. */
+
+ /*-- Go back to the first (main) directory, and get value of the EXIFIFD directory- offset. */
+ /* (directory is reloaded from file!) */
+ TIFFSetDirectory(tif, 0);
+ retCode = TIFFGetField(tif, TIFFTAG_EXIFIFD, &read_dir_offset );
+
+#ifdef READ_EXIF_TAGS
+ /*-- Now read EXIF directory from file into memory --*/
+ retCode = TIFFReadEXIFDirectory(tif, read_dir_offset);
+
+ /*-- Now get some parameters from EXIF-directory (already read into memory) --*/
+ retCode = TIFFGetField(tif, EXIFTAG_EXIFVERSION, &pAscii);
+
+
+#ifdef READ_ALL_EXIF_TAGS
+ /*-- Get array, where EXIF tag fields are defined --*/
+ tFieldArray = _TIFFGetExifFields();
+ nTags = tFieldArray->count;
+ /*-- Check, if the TiffLibrary is compiled with the new interface with Rational2Double or still uses the old definitions. */
+ /* tif points to EXIF tags, so TIFFFindField() can only access the EXIF tag fields */
+ fip = TIFFFindField(tif, EXIFTAG_EXPOSURETIME, TIFF_ANY);
+ tSetFieldType = fip->set_field_type;
+ if (tSetFieldType == TIFF_SETGET_DOUBLE) {
+ blnIsRational2Double = FALSE;
+ fprintf(stderr, "-- EXIF tags read with standard --\n");
+ } else {
+ blnIsRational2Double = TRUE;
+ fprintf(stderr, "-- Rational2Double for reading EXIF tags detected --\n");
+ }
+
+ for (i=0; i<nTags; i++) {
+ tTag = tFieldArray->fields[i].field_tag;
+ tType = tFieldArray->fields[i].field_type; /* e.g. TIFF_RATIONAL */
+ tWriteCount = tFieldArray->fields[i].field_writecount;
+ tSetFieldType = tFieldArray->fields[i].set_field_type; /* e.g. TIFF_SETGET_C0_FLOAT */
+ tFieldName = tFieldArray->fields[i].field_name;
+ pVoid = NULL;
+
+ /*-- dependent on set_field_type read value --*/
+ switch (tSetFieldType)
+ {
+ case TIFF_SETGET_ASCII:
+ /* Either the stringlength is defined as a fixed length in .field_writecount or a NULL-terminated string is used. */
+ if (!TIFFGetField( tif, tTag, &pAscii)) {
+ fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
+ GOTOFAILURE_ALL_EXIF
+ break;
+ }
+ /* Save string from temporary buffer and compare with written string. */
+ strncpy(auxCharArray, pAscii, sizeof(auxCharArray));
+ if (tWriteCount > 0) auxLong = tWriteCount-1; else auxLong = (long)strlen(auxCharArray);
+ retCode2 = strncmp(auxCharArray, auxTextArrayW[i], auxLong);
+ if (retCode2 != 0) {
+ fprintf (stderr, "%d:Read value of %s %s differs from set value %s\n", i, tFieldName, auxCharArray, auxTextArrayW[i]);
+ GOTOFAILURE_ALL_EXIF
+ }
+ break;
+ /*-- For reading, the parameter size is to be observed !! */
+ case TIFF_SETGET_UINT8:
+ case TIFF_SETGET_SINT8:
+ if (!TIFFGetField( tif, tTag, &auxChar)) {
+ fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
+ GOTOFAILURE_ALL_EXIF
+ break;
+ }
+ /* compare read values with written ones */
+ auxLong = auxChar;
+ if (auxLong != (char)auxLongArrayW[i]) {
+ fprintf (stderr, "%d:Read value of %s %ld differs from set value %ld\n", i, tFieldName, auxLong, auxLongArrayW[i]);
+ }
+ break;
+ case TIFF_SETGET_UINT16:
+ case TIFF_SETGET_SINT16:
+ if (!TIFFGetField( tif, tTag, &auxShort)) {
+ fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
+ GOTOFAILURE_ALL_EXIF
+ break;
+ }
+ /* compare read values with written ones */
+ auxLong = auxShort;
+ if (auxLong != (short)auxLongArrayW[i]) {
+ fprintf (stderr, "%d:Read value of %s %ld differs from set value %ld\n", i, tFieldName, auxLong, auxLongArrayW[i]);
+ }
+ break;
+ case TIFF_SETGET_UINT32:
+ case TIFF_SETGET_SINT32:
+ case TIFF_SETGET_IFD8:
+ case TIFF_SETGET_INT:
+ if (!TIFFGetField( tif, tTag, &auxUint32)) {
+ fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
+ GOTOFAILURE_ALL_EXIF
+ break;
+ }
+ /* compare read values with written ones */
+ auxLong = auxUint32;
+ if (auxLong != auxLongArrayW[i]) {
+ fprintf (stderr, "%d:Read value of %s %ld differs from set value %ld\n", i, tFieldName, auxLong, auxLongArrayW[i]);
+ }
+ break;
+ case TIFF_SETGET_FLOAT:
+ if (!TIFFGetField( tif, tTag, &auxFloat)) {
+ fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
+ GOTOFAILURE_ALL_EXIF
+ break;
+ }
+ /* compare read values with written ones */
+ if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) dblDiffLimit = RATIONAL_EPS*auxDoubleArrayW[i]; else dblDiffLimit = 1e-6;
+ dblDiff = auxFloat - auxDoubleArrayW[i];
+ if (fabs(dblDiff) > fabs(dblDiffLimit)) {
+ /*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value of "-1.0" if numerator equals 4294967295 (0xFFFFFFFF) to indicate infinite distance!
+ * However, there are two other EXIF tags where numerator indicates a special value and six other cases where the denominator indicates special values,
+ * which are not treated within LibTiff!!
+ */
+ if (!(tTag == EXIFTAG_SUBJECTDISTANCE && auxFloat == -1.0)) {
+ fprintf (stderr, "%d:Read value of %s %f differs from set value %f\n", i, tFieldName, auxFloat, auxDoubleArrayW[i]);
+ GOTOFAILURE_ALL_EXIF
+ }
+ }
+ break;
+ case TIFF_SETGET_DOUBLE:
+ /*-- Unfortunately, TIFF_SETGET_DOUBLE is used for TIFF_RATIONAL but those have to be read with FLOAT !!! */
+ /* Only TIFFTAG_STONITS is a TIFF_DOUBLE, which has to be read as DOUBLE!! */
+ /*-- ATTENTION: ----
+ * Only after update with Rational2Double feature, also TIFF_RATIONAL can be read in double precision!!!
+ * Therefore, use a union to avoid overflow in TIFFGetField() return value
+ * and depending on version check for the right interface here:
+ * - old interface: correct value should be here a float
+ * - new interface: correct value should be here a double
+ * Interface version (old/new) is determined above.
+ -------------------*/
+ if (!TIFFGetField(tif, tTag, &auxDblUnion.dbl)) {
+ fprintf(stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
+ GOTOFAILURE_ALL_EXIF
+ break;
+ }
+ if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) {
+ if (blnIsRational2Double) {
+ /* New interface allows also double precision for TIFF_RATIONAL */
+ auxDouble = auxDblUnion.dbl;
+ }
+ else {
+ /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE always as FLOAT */
+ auxDouble = (double)auxDblUnion.flt1;
+ }
+ }
+ else {
+ auxDouble = auxDblUnion.dbl;
+ }
+ /* compare read values with written ones */
+ if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) dblDiffLimit = RATIONAL_EPS*auxDoubleArrayW[i]; else dblDiffLimit = 1e-6;
+ dblDiff = auxDouble - auxDoubleArrayW[i];
+ if (fabs(dblDiff) > fabs(dblDiffLimit)) {
+ /*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value of "-1.0" if numerator equals 4294967295 (0xFFFFFFFF) to indicate infinite distance! */
+ if (!(tTag == EXIFTAG_SUBJECTDISTANCE && auxDouble == -1.0)) {
+ fprintf (stderr, "%d:Read value of %s %f differs from set value %f\n", i, tFieldName, auxDouble, auxDoubleArrayW[i]);
+ GOTOFAILURE_ALL_EXIF
+ }
+ }
+ break;
+
+ case TIFF_SETGET_C0_FLOAT:
+ case TIFF_SETGET_C0_DOUBLE:
+ case TIFF_SETGET_C16_FLOAT:
+ case TIFF_SETGET_C16_DOUBLE:
+ case TIFF_SETGET_C32_FLOAT:
+ case TIFF_SETGET_C32_DOUBLE:
+ /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */
+ /*-- Check, if it is a single parameter, a fixed array or a variable array */
+ if (tWriteCount == 1) {
+ fprintf (stderr, "Reading: WriteCount for .set_field_type %d should be -1 or greater than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name);
+ } else {
+ /*-- Either fix or variable array --*/
+ /* For arrays, distinguishing between float or double is essential. */
+ /* Now decide between fixed or variable array */
+ if (tWriteCount > 1) {
+ /* fixed array with needed arraysize defined in .field_writecount */
+ if (!TIFFGetField( tif, tTag, &pVoidArray)) {
+ fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
+ GOTOFAILURE_ALL_EXIF
+ break;
+ }
+ /* set tWriteCount to number of read samples for next steps */
+ auxLong = tWriteCount;
+ } else {
+ /* Special treatment of variable array. */
+ /* Dependent on Cxx, the count parameter is char, short or long. Therefore use unionLong! */
+ if (!TIFFGetField( tif, tTag, &unionLong, &pVoidArray)) {
+ fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
+ GOTOFAILURE_ALL_EXIF
+ break;
+ }
+ /* set tWriteCount to number of read samples for next steps */
+ auxLong = unionLong.Short1;
+ }
+ /* Save values from temporary array */
+ if (tSetFieldType == TIFF_SETGET_C0_FLOAT || tSetFieldType == TIFF_SETGET_C16_FLOAT || tSetFieldType == TIFF_SETGET_C32_FLOAT) {
+ memcpy(&auxFloatArray, pVoidArray,(auxLong * sizeof(auxFloatArray[0])));
+ /* compare read values with written ones */
+ if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) dblDiffLimit = RATIONAL_EPS*auxDoubleArrayW[i]; else dblDiffLimit = 1e-6;
+ for (j=0; j<auxLong; j++) {
+ dblDiff = auxFloatArray[j] - auxFloatArrayW[i+j];
+ if (fabs(dblDiff) > fabs(dblDiffLimit)) {
+ /*if (auxFloatArray[j] != (float)auxFloatArrayW[i+j]) { */
+ fprintf (stderr, "Read value %d of %s #%d %f differs from set value %f\n", i, tFieldName, j, auxFloatArray[j], auxFloatArrayW[i+j]);
+ GOTOFAILURE_ALL_EXIF
+ }
+ }
+ } else {
+ memcpy(&auxDoubleArray, pVoidArray,(auxLong * sizeof(auxDoubleArray[0])));
+ /* compare read values with written ones */
+ if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) dblDiffLimit = RATIONAL_EPS*auxDoubleArrayW[i]; else dblDiffLimit = 1e-6;
+ for (j=0; j<auxLong; j++) {
+ dblDiff = auxDoubleArray[j] - auxDoubleArrayW[i+j];
+ if (fabs(dblDiff) > fabs(dblDiffLimit)) {
+ /*if (auxDoubleArray[j] != auxDoubleArrayW[i+j]) { */
+ fprintf (stderr, "Read value %d of %s #%d %f differs from set value %f\n", i, tFieldName, j, auxDoubleArray[j], auxDoubleArrayW[i+j]);
+ GOTOFAILURE_ALL_EXIF
+ }
+ }
+ }
+ }
+ break;
+ case TIFF_SETGET_C0_UINT8:
+ case TIFF_SETGET_C0_SINT8:
+ case TIFF_SETGET_C16_UINT8:
+ case TIFF_SETGET_C16_SINT8:
+ case TIFF_SETGET_C32_UINT8:
+ case TIFF_SETGET_C32_SINT8:
+ /* For arrays, distinguishing between float or double is essential, even for writing */
+ pVoid = &auxCharArrayW[i];
+ case TIFF_SETGET_C0_UINT16:
+ case TIFF_SETGET_C0_SINT16:
+ case TIFF_SETGET_C16_UINT16:
+ case TIFF_SETGET_C16_SINT16:
+ case TIFF_SETGET_C32_UINT16:
+ case TIFF_SETGET_C32_SINT16:
+ if (pVoid == NULL) pVoid = &auxShortArrayW[i];
+ case TIFF_SETGET_C0_UINT32:
+ case TIFF_SETGET_C0_SINT32:
+ case TIFF_SETGET_C16_UINT32:
+ case TIFF_SETGET_C16_SINT32:
+ case TIFF_SETGET_C32_UINT32:
+ case TIFF_SETGET_C32_SINT32:
+ if (pVoid == NULL) pVoid = &auxLongArrayW[i];
+ /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */
+ /*-- Check, if it is a single parameter, a fixed array or a variable array */
+ if (tWriteCount == 1) {
+ fprintf (stderr, "WriteCount for .set_field_type %d should be -1 or greater than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name);
+ } else {
+ /*-- Either fix or variable array --*/
+ /* Now decide between fixed or variable array */
+ if (tWriteCount > 1) {
+ /* fixed array with needed arraysize defined in .field_writecount */
+ if (!TIFFGetField( tif, tTag, &pVoidArray)) {
+ fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
+ GOTOFAILURE_ALL_EXIF
+ break;
+ }
+ /* set tWriteCount to number of read samples for next steps */
+ auxLong = tWriteCount;
+ } else {
+ /* special treatment of variable array */
+ /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */
+ if (!TIFFGetField( tif, tTag, &unionLong, &pVoidArray)) {
+ fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name);
+ GOTOFAILURE_ALL_EXIF
+ break;
+ }
+ /* set tWriteCount to number of read samples for next steps */
+ auxLong = unionLong.Short1;
+ }
+ /* Save values from temporary array */
+ if (tSetFieldType == TIFF_SETGET_C0_UINT8 || tSetFieldType == TIFF_SETGET_C0_SINT8 ||
+ tSetFieldType == TIFF_SETGET_C16_UINT8 || tSetFieldType == TIFF_SETGET_C16_SINT8 ||
+ tSetFieldType == TIFF_SETGET_C32_UINT8 || tSetFieldType == TIFF_SETGET_C32_SINT8 ) {
+ memcpy(&auxCharArray, pVoidArray,(auxLong * sizeof(auxCharArray[0])));
+ /* Compare and check values */
+ for (j=0; j<auxLong; j++) {
+ if (tTag == EXIFTAG_EXIFVERSION) {
+ /*-- Use exifVersion[] instead of auxCharArrayW[] for differently set EXIFVERSION tag */
+ if (auxCharArray[j] != exifVersion[j]) {
+ fprintf(stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, j, auxCharArray[j], auxCharArrayW[i + j]);
+ GOTOFAILURE_ALL_EXIF
+ }
+ } else {
+ if (auxCharArray[j] != auxCharArrayW[i + j]) {
+ fprintf(stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, j, auxCharArray[j], auxCharArrayW[i + j]);
+ GOTOFAILURE_ALL_EXIF
+ }
+ }
+ }
+ } else if (tSetFieldType == TIFF_SETGET_C0_UINT16 || tSetFieldType == TIFF_SETGET_C0_SINT16 ||
+ tSetFieldType == TIFF_SETGET_C16_UINT16 || tSetFieldType == TIFF_SETGET_C16_SINT16 ||
+ tSetFieldType == TIFF_SETGET_C32_UINT16 || tSetFieldType == TIFF_SETGET_C32_SINT16 ) {
+ memcpy(&auxShortArray, pVoidArray,(auxLong * sizeof(auxShortArray[0])));
+ /* Compare and check values */
+ for (j=0; j<auxLong; j++) {
+ if (auxShortArray[j] != auxShortArrayW[i+j]) {
+ fprintf (stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, j, auxShortArray[j], auxShortArrayW[i+j]);
+ GOTOFAILURE_ALL_EXIF
+ }
+ }
+ } else if (tSetFieldType == TIFF_SETGET_C0_UINT32 || tSetFieldType == TIFF_SETGET_C0_SINT32 ||
+ tSetFieldType == TIFF_SETGET_C16_UINT32 || tSetFieldType == TIFF_SETGET_C16_SINT32 ||
+ tSetFieldType == TIFF_SETGET_C32_UINT32 || tSetFieldType == TIFF_SETGET_C32_SINT32 ) {
+ memcpy(&auxLongArray, pVoidArray,(auxLong * sizeof(auxLongArray[0])));
+ /* Compare and check values */
+ for (j=0; j<auxLong; j++) {
+ if (auxLongArray[j] != auxLongArrayW[i+j]) {
+ fprintf (stderr, "Read value %d of %s #%d %ld differs from set value %ld\n", i, tFieldName, j, auxLongArray[j], auxLongArrayW[i+j]);
+ GOTOFAILURE_ALL_EXIF
+ }
+ }
+ } else {
+ fprintf (stderr, "SetFieldType %d not defined within switch case reading for UINT for %s.\n", tSetFieldType, tFieldName);
+ GOTOFAILURE
+ }
+ }
+ break;
+ default:
+ fprintf (stderr, "SetFieldType %d not defined within writing switch for %s.\n", tSetFieldType, tFieldName);
+ GOTOFAILURE
+ }; /*-- switch() --*/
+ } /*-- for() --*/
+ /*================= EXIF: END Reading arbitrary data to the EXIF fields END END END ==============*/
+#endif /*-- READ_ALL_EXIF_TAGS --*/
+#endif /*-- READ_EXIF_TAGS --*/
+
+
+
+
+ TIFFClose(tif);
+
+ /* All tests passed; delete file and exit with success status. */
+#ifdef FOR_AUTO_TESTING
+ unlink(filenameRead);
+#endif
+ fprintf(stderr, "-------- Test finished OK ----------\n");
+ return 0;
+
+failure:
+ /*
+ * Something goes wrong; close file and return unsuccessful status.
+ * Do not remove the file for further manual investigation.
+ */
+ TIFFClose(tif);
+ fprintf(stderr, "-------- Test finished with FAILURE --------\n");
+ return 1;
+}
diff --git a/test/defer_strile_writing.c b/test/defer_strile_writing.c
index 4e358567..b918a228 100644
--- a/test/defer_strile_writing.c
+++ b/test/defer_strile_writing.c
@@ -131,7 +131,7 @@ int test(const char* mode, int tiled, int height)
ret = TIFFForceStrileArrayWriting(tif);
assert(ret);
- /* Now write data on frist directory */
+ /* Now write data on first directory */
ret = TIFFSetDirectory( tif, 0 );
assert(ret);
diff --git a/test/raw_decode.c b/test/raw_decode.c
index a2fca03a..aeaaf051 100644
--- a/test/raw_decode.c
+++ b/test/raw_decode.c
@@ -59,7 +59,7 @@
"JPEGLib: JPEG parameter struct mismatch: library thinks size is 432,
caller expects 464"
- For such users we wil fix the problem here. See install.doc file from
+ For such users we will fix the problem here. See install.doc file from
the JPEG library distribution for details.
*/
@@ -271,7 +271,7 @@ main(int argc, char **argv)
/*
* Currently TIFFReadRGBATile() just uses JPEGCOLORMODE_RGB so this
- * trivally matches the last results. Eventually we should actually
+ * trivially matches the last results. Eventually we should actually
* accomplish it from the YCbCr subsampled buffer ourselves in which
* case the results may be subtly different but similar.
*/
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index ff2a1ddc..1632fb6c 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -94,6 +94,8 @@ install(TARGETS fax2ps
pal2rgb
ppm2tiff
raw2tiff
+ rgb2ycbcr
+ thumbnail
tiff2bw
tiff2pdf
tiff2ps
diff --git a/tools/thumbnail.c b/tools/thumbnail.c
index 737780d8..94b78a81 100644
--- a/tools/thumbnail.c
+++ b/tools/thumbnail.c
@@ -657,7 +657,7 @@ generateThumbnail(TIFF* in, TIFF* out)
TIFFWriteDirectory(out) != -1);
}
-const char* stuff[] = {
+const char* usage_info[] = {
"usage: thumbnail [options] input.tif output.tif",
"where options are:",
" -h # specify thumbnail image height (default is 274)",
@@ -680,8 +680,8 @@ usage(int code)
FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr;
fprintf(out, "%s\n\n", TIFFGetVersion());
- for (i = 0; stuff[i] != NULL; i++)
- fprintf(out, "%s\n", stuff[i]);
+ for (i = 0; usage_info[i] != NULL; i++)
+ fprintf(out, "%s\n", usage_info[i]);
exit(code);
}
diff --git a/tools/tiff2ps.c b/tools/tiff2ps.c
index b9762883..32c0f702 100644
--- a/tools/tiff2ps.c
+++ b/tools/tiff2ps.c
@@ -64,7 +64,7 @@
* warning messages for incompatible command line options.
* Add new command line options to specify PageOrientation
* Document Structuring Comment for landscape or portrait
- * and code to determine the values from ouput width and height
+ * and code to determine the values from output width and height
* if not specified on the command line.
* Add new command line option to specify document creator
* as an alterntive to the string "tiff2ps" following model
@@ -85,7 +85,7 @@
*
* Identified incompatible options and returned errors, eg
* -i for imagemask operator is only available for Level2 or
- * Level3 Postscript in the current implmentation since there
+ * Level3 Postscript in the current implementation since there
* is a difference in the way the operands are called for Level1
* and there is no function to provide the Level1 version.
* -H was not handled properly if -h and/or -w were specified.
@@ -96,7 +96,7 @@
* Conversion of TIFF to Postscript with optional rotations
* of 90, 180, 270, or auto degrees counterclockwise
* Conversion of TIFF to Postscript with entire image scaled
- * to maximum of values spedified with -h or -w while
+ * to maximum of values specified with -h or -w while
* maintaining aspect ratio. Same rotations apply.
* Conversion of TIFF to Postscript with clipping of output
* viewport to height specified with -H, producing multiple
@@ -438,7 +438,7 @@ main(int argc, char* argv[])
{
if ((level2 == FALSE) && (level3 == FALSE))
{
- TIFFError ("-m "," imagemask operator requres Postscript Level2 or Level3");
+ TIFFError ("-m "," imagemask operator requires Postscript Level2 or Level3");
exit (EXIT_FAILURE);
}
}
@@ -1312,19 +1312,19 @@ int psStart(FILE *fd, int npages, int auto_rotate, int *rotation, double *scale,
if (((maxsource == pswidth) && (maxtarget != reqwidth)) ||
((maxsource == psheight) && (maxtarget != reqheight)))
- { /* optimal orientaion does not match input orientation */
+ { /* optimal orientation does not match input orientation */
*rotation = 90;
xscale = (reqwidth - left_offset)/psheight;
yscale = (reqheight - bottom_offset)/pswidth;
}
- else /* optimal orientaion matches input orientation */
+ else /* optimal orientation matches input orientation */
{
xscale = (reqwidth - left_offset)/pswidth;
yscale = (reqheight - bottom_offset)/psheight;
}
*scale = (xscale < yscale) ? xscale : yscale;
- /* Do not scale image beyound original size */
+ /* Do not scale image beyond original size */
if (*scale > 1.0)
*scale = 1.0;
@@ -1594,7 +1594,7 @@ int TIFF2PS(FILE* fd, TIFF* tif, double pgwidth, double pgheight, double lm, dou
{
if (pgwidth != 0 || pgheight != 0)
{
- /* User did not specify a maxium page height or width using -H or -W flag
+ /* User did not specify a maximum page height or width using -H or -W flag
* but did use -h or -w flag to scale to a specific size page.
*/
npages++;
@@ -1765,7 +1765,7 @@ PS_Lvl2colorspace(FILE* fd, TIFF* tif)
/*
* Set up PostScript Level 2 colorspace according to
- * section 4.8 in the PostScript refenence manual.
+ * section 4.8 in the PostScript reference manual.
*/
fputs("% PostScript Level 2 only.\n", fd);
if (photometric != PHOTOMETRIC_PALETTE) {
@@ -1927,7 +1927,7 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h)
case COMPRESSION_CCITTFAX4:
/*
* Manage inverting with /Blackis1 flag
- * since there migth be uncompressed parts
+ * since there might be uncompressed parts
*/
fputs(" /Decode [0 1]\n", fd);
break;
diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
index df2707e3..805ea0c0 100644
--- a/tools/tiffcrop.c
+++ b/tools/tiffcrop.c
@@ -102,7 +102,7 @@
* includes annotations for image parameters and scanline info. Level
* selects which functions dump data, with higher numbers selecting
* lower level, scanline level routines. Debug reports a limited set
- * of messages to monitor progess without enabling dump logs.
+ * of messages to monitor progress without enabling dump logs.
*/
static char tiffcrop_version_id[] = "2.4";
@@ -1933,11 +1933,11 @@ void process_command_opts (int argc, char *argv[], char *mp, char *mode, uint32
TIFFError ("For valid options type", "tiffcrop -h");
exit (EXIT_FAILURE);
break;
- case 'J': /* horizontal margin for sectioned ouput pages */
+ case 'J': /* horizontal margin for sectioned output pages */
page->hmargin = atof(optarg);
page->mode |= PAGE_MODE_MARGINS;
break;
- case 'K': /* vertical margin for sectioned ouput pages*/
+ case 'K': /* vertical margin for sectioned output pages*/
page->vmargin = atof(optarg);
page->mode |= PAGE_MODE_MARGINS;
break;
@@ -5899,7 +5899,7 @@ loadImage(TIFF* in, struct image_data *image, struct dump_opts *dump, unsigned c
TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &planar);
TIFFGetFieldDefaulted(in, TIFFTAG_ORIENTATION, &orientation);
if (! TIFFGetFieldDefaulted(in, TIFFTAG_PHOTOMETRIC, &input_photometric))
- TIFFError("loadImage","Image lacks Photometric interpreation tag");
+ TIFFError("loadImage","Image lacks Photometric interpretation tag");
if (! TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width))
TIFFError("loadimage","Image lacks image width tag");
if(! TIFFGetField(in, TIFFTAG_IMAGELENGTH, &length))
@@ -7655,7 +7655,7 @@ processCropSelections(struct image_data *image, struct crop_mask *crop,
/* Copy the crop section of the data from the current image into a buffer
* and adjust the IFD values to reflect the new size. If no cropping is
- * required, use the origial read buffer as the crop buffer.
+ * required, use the original read buffer as the crop buffer.
*
* There is quite a bit of redundancy between this routine and the more
* specialized processCropSelections, but this provides