libtiff: v3.4beta036 release

From 7b7dc6a9696b7d7fb1c2fcdd355ee0e3a9d22c2d Mon Sep 17 00:00:00 2001
From: Sam Leffler <[EMAIL REDACTED]>
Date: Fri, 21 Feb 1997 01:20:19 +0000
Subject: [PATCH] v3.4beta036 release

---
 Makefile.in            |   4 +-
 configure              |  29 +++++++----
 dist/tiff.alpha        |   2 +-
 html/Makefile.in       |   4 +-
 html/document.html     |   4 +-
 html/index.html        |   4 +-
 html/internals.html    |  12 ++++-
 html/libtiff.html      |   6 +--
 html/v3.4beta035.html  |  62 ++++++++++++++++++++++
 html/v3.4beta036.html  | 116 +++++++++++++++++++++++++++++++++++++++++
 libtiff/Makefile.in    |   6 +--
 libtiff/t4.h           |   2 +-
 libtiff/tif_aux.c      |   5 +-
 libtiff/tif_close.c    |   5 +-
 libtiff/tif_compress.c |  16 ++++--
 libtiff/tif_dir.c      |  30 ++++++++++-
 libtiff/tif_dir.h      |  18 +++++--
 libtiff/tif_dirinfo.c  |  10 +++-
 libtiff/tif_dirread.c  |  30 +++++------
 libtiff/tif_dirwrite.c |  33 ++++++------
 libtiff/tif_fax3.c     |   4 +-
 libtiff/tif_fax3.h     |  14 ++---
 libtiff/tif_getimage.c |  10 ++--
 libtiff/tif_jpeg.c     |   8 +--
 libtiff/tif_lzw.c      |  11 ++--
 libtiff/tif_open.c     |  13 +++--
 libtiff/tif_pixarlog.c |  12 ++---
 libtiff/tif_print.c    |  11 +++-
 libtiff/tif_read.c     |  48 ++++++++++++-----
 libtiff/tif_zip.c      |  14 ++---
 libtiff/tiff.h         |   7 ++-
 libtiff/tiffconf.h     |  13 +++--
 libtiff/tiffio.h       |  14 +++--
 libtiff/tiffiop.h      |   3 +-
 man/TIFFGetField.3t    |   8 ++-
 man/TIFFOpen.3t        |  15 +++---
 man/TIFFSetField.3t    |  13 ++++-
 man/libtiff.3t         |   5 +-
 man/tiff2ps.1          |  46 +++++++++-------
 man/tiffcp.1           |   9 ++--
 man/tiffinfo.1         |   7 ++-
 tools/Makefile.in      |   6 +--
 tools/pal2rgb.c        |   4 +-
 tools/sgigt.c          |   6 +--
 tools/tiff2ps.c        |  41 +++++++++++----
 tools/tiffcp.c         |   8 ++-
 tools/tiffdump.c       |  27 +++++++---
 tools/tiffinfo.c       |  11 ++--
 48 files changed, 576 insertions(+), 210 deletions(-)
 create mode 100644 html/v3.4beta035.html
 create mode 100644 html/v3.4beta036.html

diff --git a/Makefile.in b/Makefile.in
index 055c7f81..6389aef0 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,5 +1,5 @@
 #! smake
-#	$Header: /usr/people/sam/tiff/RCS/Makefile.in,v 1.57 1996/06/10 22:24:41 sam Exp $
+#	$Header: /usr/people/sam/tiff/RCS/Makefile.in,v 1.58 1997/02/21 01:20:19 sam Exp $
 #
 # @WARNING@
 #
@@ -272,6 +272,8 @@ TIFFFILES=\
 	    html/misc.html			\
 	    html/support.html			\
 	    html/tools.html			\
+	    html/v3.4beta036.html		\
+	    html/v3.4beta035.html		\
 	    html/v3.4beta034.html		\
 	    html/v3.4beta033.html		\
 	    html/v3.4beta032.html		\
diff --git a/configure b/configure
index 92b2b5c4..5149317f 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #!/bin/sh
-#	$Header: /usr/people/sam/tiff/RCS/configure,v 1.52 1996/06/10 20:48:14 sam Exp $
+#	$Header: /usr/people/sam/tiff/RCS/configure,v 1.56 1997/01/28 00:39:52 sam Exp $
 #
 # Tag Image File Format (TIFF) Software
 #
@@ -147,7 +147,7 @@ do
     -target|--target)		ac_prev=TARGET;;
     -target=*|--target=*)	TARGET="$ac_optarg" ;;
     -version|--version)
-	echo "This is TIFF configure $Revision: 1.52 $"
+	echo "This is TIFF configure $Revision: 1.56 $"
 	exit 0
 	;;
     -help|--help)		usage; exit 0;;
@@ -1093,6 +1093,7 @@ if [ "$DSO" = auto ]; then
 	    DSOSUF=so
 	    DSOOPTS='-elf -shared -no_unresolved -all'
 	    DSO=IRIX52
+	    TIFFLIBREF='-L${DEPTH}/libtiff -rpath '${DIR_LIB}' -ltiff'
 	fi
 	;;
     *-irix*)
@@ -1101,6 +1102,7 @@ if [ "$DSO" = auto ]; then
 	    DSOLD="${CCOMPILER} ${ENVOPTS}"
 	    DSOOPTS='-shared -rdata_shared -check_registry ${SRCDIR}/port/irix/so_locations -quickstart_info'
 	    DSO=IRIX
+	    TIFFLIBREF='-L${DEPTH}/libtiff -rpath '${DIR_LIB}' -ltiff'
 	fi
 	;;
     *-aix*)
@@ -1109,24 +1111,31 @@ if [ "$DSO" = auto ]; then
 	LIBCOPTS="-bM\:SRE"
 	DSO=AIX
 	;;
+    *-hpux*yes)
+        DSOSUF=sl
+        DSOLD=gcc
+        DSOOPTS='-fpic -shared'
+        LIBCOPTS=-fpic
+        DSO=HPUX
+        ;;		 
     *-hpux*)
 	DSOSUF=sl
 	DSOOPTS='-b'
 	LIBCOPTS="+Z"
 #	LIBPORT="-Wl,+b${DIR_LIB}"
 	DSO=HPUX
-	;;
-    *-solaris*-yes)
-	DSOSUF=so
-	DSOOPTS='-G'
-	LIBCOPTS="-fpic"
-	DSO=SOLARIS
+	TIFFLIBREF="-Wl,+s,+b${DIR_LIB}"' -L${DEPTH}/libtiff -ltiff'
 	;;
     *-solaris*)
 	DSOSUF=so
 	DSOOPTS='-G'
-	LIBCOPTS="-K PIC"
+	if [ $ISGCC = yes ]; then
+	    LIBCOPTS="-fpic"
+	else
+	    LIBCOPTS="-K PIC"
+	fi
 	DSO=SOLARIS
+	TIFFLIBREF='-L${DEPTH}/libtiff -R'${DIR_LIB}' -ltiff'
 	;;
     *-netbsd*)
 	DSOSUF=so.${DIST_MAJOR}.0
@@ -1141,7 +1150,7 @@ if [ "$DSO" = auto ]; then
 	TIFFLIBREF='-L${DEPTH}/libtiff -ltiff'
 	;;
     *-linux*)
-	if [ -x /lib/libc.so.5 ]; then
+	if [ -r /lib/libc.so.5 ]; then
 	    DSOSUF=so.${DIST_MAJOR}
 	    DSOSUF_VERSION=${DSOSUF}.${DIST_MINOR}.${DIST_ALPHA}
 	    LIBCOPTS='-fPIC'
diff --git a/dist/tiff.alpha b/dist/tiff.alpha
index c6261fe1..21bf733e 100644
--- a/dist/tiff.alpha
+++ b/dist/tiff.alpha
@@ -1 +1 @@
-define ALPHA 035
+define ALPHA 036
diff --git a/html/Makefile.in b/html/Makefile.in
index c443ee71..8e6b677c 100644
--- a/html/Makefile.in
+++ b/html/Makefile.in
@@ -1,4 +1,4 @@
-#	$Header: /usr/people/sam/tiff/html/RCS/Makefile.in,v 1.13 1996/06/05 21:43:27 sam Exp $
+#	$Header: /usr/people/sam/tiff/html/RCS/Makefile.in,v 1.14 1997/02/21 01:20:12 sam Exp $
 #
 # @WARNING@
 #
@@ -71,6 +71,8 @@ HTMLFILES=\
 	v3.4beta032.html	\
 	v3.4beta033.html	\
 	v3.4beta034.html	\
+	v3.4beta035.html	\
+	v3.4beta036.html	\
 	${NULL}
 IMAGES=\
 	images/back.gif		\
diff --git a/html/document.html b/html/document.html
index 38434774..2e200e24 100644
--- a/html/document.html
+++ b/html/document.html
@@ -39,7 +39,7 @@ <H5>
 Acrobat format (PDF); this can be found at
 
 <UL>
-<A HREF="ftp://ftp.adobe.com/pub/adobe/DeveloperSupport/TechNotes/PDFfiles/TIFF6.pdf">ftp://ftp.adobe.com/pub/adobe/DeveloperSupport/TechNotes/PDFfiles/TIFF6.pdf</A>
+<A HREF="ftp://ftp.adobe.com/pub/adobe/devrelations/devtechnotes/pdffiles/tiff6.pdf">ftp://ftp.adobe.com/pub/adobe/devrelations/devtechnotes/pdffiles/tiff6.pdf</A>
 </UL>
 
 TIFF Technical Notes can be retrieved from
@@ -53,7 +53,7 @@ <H5>
 
 <ADDRESS>
 <A HREF="sam.html">Sam Leffler</A> / <A HREF="mailto:sam@engr.sgi.com">sam@engr.sgi.com</A>.
-Last updated: $Date: 1996/04/29 19:18:06 $
+Last updated: $Date: 1996/11/10 16:39:43 $
 </ADDRESS>
 
 </BODY>
diff --git a/html/index.html b/html/index.html
index e6c7a26e..6934f31d 100644
--- a/html/index.html
+++ b/html/index.html
@@ -12,7 +12,7 @@ <H1>
 </H1>
 
 <B>Latest Release</B>: <A HREF="v3.4beta033.html">v3.4</A><BR>
-<B>Latest Software</B>: <A HREF="v3.4beta034.html">v3.4beta034</A><BR>
+<B>Latest Software</B>: <A HREF="v3.4beta036.html">v3.4beta036</A><BR>
 <B>Master FTP Site</B>: <A HREF="ftp://ftp.sgi.com/graphics/tiff">ftp.sgi.com (192.48.153.1), directory graphics/tiff</A><BR>
 <B>Home Page</B>: <A HREF="http://www-mipl.jpl.nasa.gov/~ndr/tiff/">
   http://www-mipl.jpl.nasa.gov/~ndr/tiff/</A> <BR>
@@ -81,7 +81,7 @@ <H5>
 
 <ADDRESS>
 <A HREF="sam.html">Sam Leffler</A> / <A HREF="mailto:sam@engr.sgi.com">sam@engr.sgi.com</A>.
-Last updated: $Date: 1996/05/21 19:01:11 $
+Last updated: $Date: 1997/02/21 01:20:12 $
 </ADDRESS>
 
 </BODY>
diff --git a/html/internals.html b/html/internals.html
index 94f8c29d..756b5ab0 100644
--- a/html/internals.html
+++ b/html/internals.html
@@ -199,6 +199,16 @@ <H5>
 <TD>support for the TIFF 6.0 CMYK-related tags</TD>
 </TR>
 
+<TR>
+<TD VALIGN=top><TT>ICC_SUPPORT</TT></TD>
+<TD>support for the ICC Profile tag; see
+<I>The ICC Profile Format Specification</I>,
+Annex B.3 "Embedding ICC Profiles in TIFF Files";
+available at
+<A HREF=http://www.color.org>http://www.color.org</A>
+</TD>
+</TR>
+
 </TABLE>
 
 
@@ -639,7 +649,7 @@ <H5>
 
 <ADDRESS>
 <A HREF="sam.html">Sam Leffler</A> / <A HREF="mailto:sam@engr.sgi.com">sam@engr.sgi.com</A>.
-Last updated: $Date: 1996/04/29 19:18:06 $
+Last updated: $Date: 1996/12/13 05:31:06 $
 </ADDRESS>
 
 </BODY>
diff --git a/html/libtiff.html b/html/libtiff.html
index 7fffe63e..75607d77 100644
--- a/html/libtiff.html
+++ b/html/libtiff.html
@@ -230,7 +230,7 @@ <H5>
 {
     TIFF* tif = TIFFOpen(argv[1], "r");
     if (tif) {
-	int dircount = 1;
+	int dircount = 0;
 	do {
 	    dircount++;
 	} while (TIFFReadDirectory(tif));
@@ -375,7 +375,7 @@ <H5>
 	npixels = w * h;
 	raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32));
 	if (raster != NULL) {
-	    if (TIFFReadRGBAImage(tif, raster, w, h, 0)) {
+	    if (TIFFReadRGBAImage(tif, w, h, raster, 0)) {
 		...process raster data...
 	    }
 	    _TIFFfree(raster);
@@ -738,7 +738,7 @@ <H5>
 
 <ADDRESS>
 <A HREF="sam.html">Sam Leffler</A> / <A HREF="mailto:sam@engr.sgi.com">sam@engr.sgi.com</A>.
-Last updated: $Date: 1996/04/29 19:18:06 $
+Last updated: $Date: 1996/08/29 01:08:05 $
 </ADDRESS>
 
 </BODY>
diff --git a/html/v3.4beta035.html b/html/v3.4beta035.html
new file mode 100644
index 00000000..56433968
--- /dev/null
+++ b/html/v3.4beta035.html
@@ -0,0 +1,62 @@
+<HTML>
+<HEAD>
+<TITLE>
+Changes in TIFF v3.4beta035
+</TITLE>
+</HEAD>
+
+<BODY>
+
+<BASEFONT SIZE=4>
+<B><FONT SIZE=+3>T</FONT>IFF <FONT SIZE=+2>C</FONT>HANGE <FONT SIZE=+2>I</FONT>NFORMATION</B>
+<BASEFONT SIZE=3>
+
+<UL>
+<HR SIZE=4 WIDTH=65% ALIGN=left>
+<B>Current Version</B>: v3.4beta035<BR>
+<B>Previous Version</B>: <A HREF=v3.4beta034.html>v3.4beta034</A><BR>
+<B>Master FTP Site</B>: <A HREF="ftp://ftp.sgi.com/graphics/tiff">ftp.sgi.com (192.48.153.1), directory graphics/tiff</A><BR>
+<HR SIZE=4 WIDTH=65% ALIGN=left>
+</UL>
+
+<P>
+This document describes the changes made to the software between the
+<I>previous</I> and <I>current</I> versions (see above).
+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="#configure">Changes in the software configuration</A>
+<LI><A HREF="#libtiff">Changes in libtiff</A>
+</UL>
+
+<P><HR WIDTH=65% ALIGN=right>
+
+<A NAME="configure"><B><FONT SIZE=+3>C</FONT>HANGES IN THE SOFTWARE CONFIGURATION:</B></A>
+
+<UL>
+<LI>support was added installing the HTML documentation
+<LI>support was added for building the library as a DSO under FreeBSD
+</UL>
+
+<P><HR WIDTH=65% ALIGN=right>
+
+<A NAME="libtiff"><B><FONT SIZE=+3>C</FONT>HANGES IN LIBTIFF:</B></A>
+
+<UL>
+<LI>the interface to the <B>mkversion</B> program was restored to
+    the form used prior to v3.4beta034
+<LI>several portability problems for 16-bit systems were fixed
+</UL>
+
+<A HREF="index.html"><IMG SRC="images/back.gif"></A> TIFF home page.<BR>
+
+<HR>
+
+<ADDRESS>
+<A HREF="sam.html">Sam Leffler</A> / <A HREF="mailto:sam@engr.sgi.com">sam@engr.sgi.com</A>
+Last updated $Date: 1997/02/21 01:20:07 $.
+</ADDRESS>
+
+</BODY>
+</HTML>
diff --git a/html/v3.4beta036.html b/html/v3.4beta036.html
new file mode 100644
index 00000000..22a62270
--- /dev/null
+++ b/html/v3.4beta036.html
@@ -0,0 +1,116 @@
+<HTML>
+<HEAD>
+<TITLE>
+Changes in TIFF v3.4beta036
+</TITLE>
+</HEAD>
+
+<BODY>
+
+<BASEFONT SIZE=4>
+<B><FONT SIZE=+3>T</FONT>IFF <FONT SIZE=+2>C</FONT>HANGE <FONT SIZE=+2>I</FONT>NFORMATION</B>
+<BASEFONT SIZE=3>
+
+<UL>
+<HR SIZE=4 WIDTH=65% ALIGN=left>
+<B>Current Version</B>: v3.4beta036<BR>
+<B>Previous Version</B>: <A HREF=v3.4beta035.html>v3.4beta035</A><BR>
+<B>Master FTP Site</B>: <A HREF="ftp://ftp.sgi.com/graphics/tiff">ftp.sgi.com (192.48.153.1), directory graphics/tiff</A><BR>
+<HR SIZE=4 WIDTH=65% ALIGN=left>
+</UL>
+
+<P>
+This document describes the changes made to the software between the
+<I>previous</I> and <I>current</I> versions (see above).
+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="#configure">Changes in the software configuration</A>
+<LI><A HREF="#libtiff">Changes in libtiff</A>
+<LI><A HREF="#tools">Changes in the tools</A>
+</UL>
+
+<P><HR WIDTH=65% ALIGN=right>
+
+<A NAME="configure"><B><FONT SIZE=+3>C</FONT>HANGES IN THE SOFTWARE CONFIGURATION:</B></A>
+
+<UL>
+<LI>support was added for building the library as a DSO under HP-UX with 
+    the native C compiler
+<LI>tools are now built with explicit pathnames for the DSO under IRIX,
+    Solaris, and Linux
+<LI>DSO configuration support for Linux was changed to require that
+    <B>libc.so</B> only be readable (not executable)
+</UL>
+
+<P><HR WIDTH=65% ALIGN=right>
+
+<A NAME="libtiff"><B><FONT SIZE=+3>C</FONT>HANGES IN LIBTIFF:</B></A>
+
+<UL>
+<LI>support was add for ICC: <TT>NumberOfInks</TT>, and <TT>ICCProfile</TT>
+<LI>a memory leak caused by doing <TT>TIFFSetDirectory(0)</TT> was fixed
+<LI>a bug was fixed whereby certain multi-directory files were not
+    properly handled when accessed by mapping the data into memory 
+<LI>the strip chopping support is now always compiled
+    into the library with the default usage controlled by a
+    <TT>STRIPCHOP_DEFAULT</TT> configuration parameter
+<LI>the strip chopping support no longer chops tiled images
+<LI>all static strings are now const--for shared libraries
+<LI>the logic for estimating the strip size of images without
+    a <TT>StripByteCounts</TT> tag was improved by handling
+    <TT>PlanarContig</TT> images differently from <TT>PlanarSeparate</TT>
+<LI>a bug was fixed in the G3 codec when converting the Y resolution
+    of data specified in metric units
+<LI>a bug was fixed in the G3/G4 decoder for data where lines terminate
+    with a v0 code
+<LI>the <TT>TIFFRGBAImage</TT> support was changed to scale 16-bit colormap
+    entries more conservatively to avoid problems with applications
+    that do not generate fully saturated pixel values
+<LI>the LZW decoder was changed to use a more conservative scheme when
+    bounds checking the hash table array; this avoids pitfalls with
+    systems that load objects into memory in unusual locations
+<LI>a bug was fixed in <TT>TIFFPrintDirectory</TT>'s handling of the
+    <TT>InkNames</TT> tag
+<LI><TT>TIFFPrintDirectory</TT> now understands <TT>NumberOfInks</TT>
+    and ICC-related tags
+<LI>the routines for reading image data now provide more useful information
+    when a read error is encountered
+<LI>support was added for compiling with Microsoft Visual C++ 4.0
+</UL>
+
+<P><HR WIDTH=65% ALIGN=right>
+
+<A NAME="tools"><B><FONT SIZE=+3>C</FONT>HANGES IN THE TOOLS:</B></A>
+
+<UL>
+<LI>a bug was fixed in <B>pal2rgb</B>'s colormap handling
+<LI><B>tiff2ps</B> now includes John Wehle's changes for maintaining 
+    the aspect ratio
+    of images when scaling and for honoring the deadzone on a page when
+    generating PostScript Level II
+<LI><B>tiff2ps</B> does a better job guarding against the mishandling
+    of greyscale images
+<LI><B>tiff2ps</B> now correctly converts X- and Y-resolution values
+    specified in metric units
+<LI><B>tiffdump</B> has a new <TT>-m</TT> option to control the maximum
+    number of indirect
+    data values printed for a tag (by default 24)
+<LI><B>tiffdump</B> understands several new tags
+<LI><B>tiffdump</B> now shows any terminating null in ASCII strings
+<LI><B>tiffinfo</B> now suppresses strip chopping when interpreting an image;
+    a new <TT>-z</TT> option has been added to enable strip chopping
+</UL>
+
+<A HREF="index.html"><IMG SRC="images/back.gif"></A> TIFF home page.<BR>
+
+<HR>
+
+<ADDRESS>
+<A HREF="sam.html">Sam Leffler</A> / <A HREF="mailto:sam@engr.sgi.com">sam@engr.sgi.com</A>
+Last updated $Date: 1997/02/21 01:20:07 $.
+</ADDRESS>
+
+</BODY>
+</HTML>
diff --git a/libtiff/Makefile.in b/libtiff/Makefile.in
index ede6b0b6..111e6348 100644
--- a/libtiff/Makefile.in
+++ b/libtiff/Makefile.in
@@ -1,4 +1,4 @@
-#	$Header: /usr/people/sam/tiff/libtiff/RCS/Makefile.in,v 1.38 1996/06/10 20:48:50 sam Exp $
+#	$Header: /usr/people/sam/tiff/libtiff/RCS/Makefile.in,v 1.40 1996/11/11 16:15:16 sam Exp $
 #
 # Tag Image File Format Library
 #
@@ -159,7 +159,7 @@ libtiff.a: ${OBJS}
 
 # default IRIX DSO building rule
 IRIXdso: ${OBJS}
-	${CC} -o libtiff.@DSOSUF@ -shared -rdata_shared \
+	${CC} @ENVOPTS@ -o libtiff.@DSOSUF@ -shared -rdata_shared \
 	    -check_registry ${SRCDIR}/../port/irix/so_locations \
 	    -quickstart_info \
 	    ${OBJS} @LIBJPEG@ @LIBGZ@
@@ -319,7 +319,7 @@ installDSO: @DSO@dso
 	    ${INSTALL} -idb tiff.sw.tools -F @DIR_LIB@			\
 		-ln libtiff.@DSOSUF_VERSION@ -O libtiff.@DSOSUF@;	\
 	else								\
-	    ${INSTALL} -idb tiff.sw.tools -m 444 -F @DIR_LIB@		\
+	    ${INSTALL} -idb tiff.sw.tools -m 555 -F @DIR_LIB@		\
 		-O libtiff.@DSOSUF@;					\
 	fi
 install: all installHdrs
diff --git a/libtiff/t4.h b/libtiff/t4.h
index 30dc5aef..4873d35d 100644
--- a/libtiff/t4.h
+++ b/libtiff/t4.h
@@ -1,4 +1,4 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/t4.h,v 1.15 1996/01/10 19:33:20 sam Exp $ */
+/* $Id: t4.h,v 1.16 1996/06/24 03:00:54 sam Exp $ */
 
 /*
  * Copyright (c) 1988-1996 Sam Leffler
diff --git a/libtiff/tif_aux.c b/libtiff/tif_aux.c
index debfd382..608115a6 100644
--- a/libtiff/tif_aux.c
+++ b/libtiff/tif_aux.c
@@ -1,4 +1,4 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_aux.c,v 1.32 1996/01/10 19:32:55 sam Exp $ */
+/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_aux.c,v 1.33 1996/08/01 19:10:34 sam Exp $ */
 
 /*
  * Copyright (c) 1991-1996 Sam Leffler
@@ -124,6 +124,9 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap)
 	case TIFFTAG_INKSET:
 		*va_arg(ap, uint16 *) = td->td_inkset;
 		return (1);
+	case TIFFTAG_NUMBEROFINKS:
+		*va_arg(ap, uint16 *) = td->td_ninks;
+		return (1);
 #endif
 	case TIFFTAG_EXTRASAMPLES:
 		*va_arg(ap, uint16 *) = td->td_extrasamples;
diff --git a/libtiff/tif_close.c b/libtiff/tif_close.c
index 8f416876..d45e5c65 100644
--- a/libtiff/tif_close.c
+++ b/libtiff/tif_close.c
@@ -1,4 +1,4 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_close.c,v 1.30 1996/01/10 19:32:55 sam Exp $ */
+/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_close.c,v 1.31 1997/01/27 19:09:09 sam Exp $ */
 
 /*
  * Copyright (c) 1988-1996 Sam Leffler
@@ -37,8 +37,7 @@ TIFFClose(TIFF* tif)
 		 * Flush buffered data and directory (if dirty).
 		 */
 		TIFFFlush(tif);
-	if (tif->tif_cleanup)
-		(*tif->tif_cleanup)(tif);
+	(*tif->tif_cleanup)(tif);
 	TIFFFreeDirectory(tif);
 	if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER))
 		_TIFFfree(tif->tif_rawdata);
diff --git a/libtiff/tif_compress.c b/libtiff/tif_compress.c
index ce99489e..3878d7ab 100644
--- a/libtiff/tif_compress.c
+++ b/libtiff/tif_compress.c
@@ -1,4 +1,4 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_compress.c,v 1.51 1996/01/10 19:32:57 sam Exp $ */
+/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_compress.c,v 1.52 1997/01/27 19:09:09 sam Exp $ */
 
 /*
  * Copyright (c) 1988-1996 Sam Leffler
@@ -122,11 +122,9 @@ _TIFFNoPreCode(TIFF* tif, tsample_t s)
 static int _TIFFtrue(TIFF* tif) { (void) tif; return (1); }
 static void _TIFFvoid(TIFF* tif) { (void) tif; }
 
-int
-TIFFSetCompressionScheme(TIFF* tif, int scheme)
+void
+_TIFFSetDefaultCompressionState(TIFF* tif)
 {
-	const TIFFCodec *c = TIFFFindCODEC(scheme);
-
 	tif->tif_setupdecode = _TIFFtrue;
 	tif->tif_predecode = _TIFFNoPreCode;
 	tif->tif_decoderow = _TIFFNoRowDecode;
@@ -144,6 +142,14 @@ TIFFSetCompressionScheme(TIFF* tif, int scheme)
 	tif->tif_defstripsize = _TIFFDefaultStripSize;
 	tif->tif_deftilesize = _TIFFDefaultTileSize;
 	tif->tif_flags &= ~TIFF_NOBITREV;
+}
+
+int
+TIFFSetCompressionScheme(TIFF* tif, int scheme)
+{
+	const TIFFCodec *c = TIFFFindCODEC(scheme);
+
+	_TIFFSetDefaultCompressionState(tif);
 	/*
 	 * Don't treat an unknown compression scheme as an error.
 	 * This permits applications to open files with data that
diff --git a/libtiff/tif_dir.c b/libtiff/tif_dir.c
index 82187349..d219cbdf 100644
--- a/libtiff/tif_dir.c
+++ b/libtiff/tif_dir.c
@@ -1,4 +1,4 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dir.c,v 1.156 1996/01/10 20:37:08 sam Exp $ */
+/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dir.c,v 1.158 1996/12/13 05:25:39 sam Exp $ */
 
 /*
  * Copyright (c) 1988-1996 Sam Leffler
@@ -50,6 +50,8 @@ _TIFFsetByteArray(void** vpp, void* vp, long n)
 }
 void _TIFFsetString(char** cpp, char* cp)
     { _TIFFsetByteArray((void**) cpp, (void*) cp, (long) (strlen(cp)+1)); }
+void _TIFFsetNString(char** cpp, char* cp, long n)
+    { _TIFFsetByteArray((void**) cpp, (void*) cp, n); }
 void _TIFFsetShortArray(uint16** wpp, uint16* wp, long n)
     { _TIFFsetByteArray((void**) wpp, (void*) wp, n*sizeof (uint16)); }
 void _TIFFsetLongArray(uint32** lpp, uint32* lp, long n)
@@ -364,11 +366,22 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
 		td->td_dotrange[1] = (uint16) va_arg(ap, int);
 		break;
 	case TIFFTAG_INKNAMES:
-		_TIFFsetString(&td->td_inknames, va_arg(ap, char*));
+		i = va_arg(ap, int);
+		_TIFFsetNString(&td->td_inknames, va_arg(ap, char*), i);
+		break;
+	case TIFFTAG_NUMBEROFINKS:
+		td->td_ninks = (uint16) va_arg(ap, int);
 		break;
 	case TIFFTAG_TARGETPRINTER:
 		_TIFFsetString(&td->td_targetprinter, va_arg(ap, char*));
 		break;
+#endif
+#ifdef ICC_SUPPORT
+	case TIFFTAG_ICCPROFILE:
+		td->td_profileLength = (uint32) va_arg(ap, uint32);
+		_TIFFsetByteArray(&td->td_profileData, va_arg(ap, void*),
+		    td->td_profileLength);
+		break;
 #endif
 	default:
 		/*
@@ -677,9 +690,18 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
 	case TIFFTAG_INKNAMES:
 		*va_arg(ap, char**) = td->td_inknames;
 		break;
+	case TIFFTAG_NUMBEROFINKS:
+		*va_arg(ap, uint16*) = td->td_ninks;
+		break;
 	case TIFFTAG_TARGETPRINTER:
 		*va_arg(ap, char**) = td->td_targetprinter;
 		break;
+#endif
+#ifdef ICC_SUPPORT
+	case TIFFTAG_ICCPROFILE:
+		*va_arg(ap, uint32*) = td->td_profileLength;
+		*va_arg(ap, void**) = td->td_profileData;
+		break;
 #endif
 	default:
 		/*
@@ -774,6 +796,9 @@ TIFFFreeDirectory(TIFF* tif)
 	CleanupField(td_transferfunction[0]);
 	CleanupField(td_transferfunction[1]);
 	CleanupField(td_transferfunction[2]);
+#endif
+#ifdef ICC_SUPPORT
+	CleanupField(td_profileData);
 #endif
 	CleanupField(td_stripoffset);
 	CleanupField(td_stripbytecount);
@@ -822,6 +847,7 @@ TIFFDefaultDirectory(TIFF* tif)
 #endif
 #ifdef CMYK_SUPPORT
 	td->td_inkset = INKSET_CMYK;
+	td->td_ninks = 4;
 #endif
 	tif->tif_postdecode = _TIFFNoPostDecode;
 	tif->tif_vsetfield = _TIFFVSetField;
diff --git a/libtiff/tif_dir.h b/libtiff/tif_dir.h
index c2021dfa..f9eac232 100644
--- a/libtiff/tif_dir.h
+++ b/libtiff/tif_dir.h
@@ -1,4 +1,4 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dir.h,v 1.4 1996/01/10 19:33:21 sam Exp $ */
+/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dir.h,v 1.6 1996/12/13 05:25:17 sam Exp $ */
 
 /*
  * Copyright (c) 1988-1996 Sam Leffler
@@ -91,10 +91,15 @@ typedef	struct {
 #endif
 #ifdef CMYK_SUPPORT
 	uint16	td_inkset;
+	uint16	td_ninks;
 	uint16	td_dotrange[2];
 	char*	td_inknames;
 	char*	td_targetprinter;
 #endif
+#ifdef ICC_SUPPORT
+	uint32	td_profileLength;
+	void	*td_profileData;
+#endif
 } TIFFDirectory;
 
 /*
@@ -165,8 +170,10 @@ typedef	struct {
 #define	FIELD_DOTRANGE			47
 #define	FIELD_TARGETPRINTER		48
 #define	FIELD_SUBIFD			49
-
-#define	FIELD_CODEC			50	/* base of codec-private tags */
+#define	FIELD_NUMBEROFINKS		50
+#define FIELD_ICCPROFILE		51
+/* end of support for well-known tags; codec-private tags follow */
+#define	FIELD_CODEC			51	/* base of codec-private tags */
 /*
  * Pseudo-tags don't normally need field bits since they
  * are not written to an output file (by definition).
@@ -192,8 +199,8 @@ typedef	struct {
 
 typedef	struct {
 	ttag_t	field_tag;		/* field's tag */
-	short	field_readcount;	/* read count (-1 for unknown) */
-	short	field_writecount;	/* write count (-1 for unknown) */
+	short	field_readcount;	/* read count/TIFF_VARIABLE/TIFF_SPP */
+	short	field_writecount;	/* write count/TIFF_VARIABLE */
 	TIFFDataType field_type;	/* type of associated data */
 	u_short	field_bit;		/* bit in fieldsset bit vector */
 	u_char	field_oktochange;	/* if true, can change while writing */
@@ -204,6 +211,7 @@ typedef	struct {
 #define	TIFF_ANY	TIFF_NOTYPE	/* for field descriptor searching */
 #define	TIFF_VARIABLE	-1		/* marker for variable length tags */
 #define	TIFF_SPP	-2		/* marker for SamplesPerPixel tags */
+#define	TIFF_VARIABLE2	-3		/* marker for uint32 var-length tags */
 
 extern	const int tiffDataWidth[];	/* table of tag datatype widths */
 
diff --git a/libtiff/tif_dirinfo.c b/libtiff/tif_dirinfo.c
index 436165f5..c4584647 100644
--- a/libtiff/tif_dirinfo.c
+++ b/libtiff/tif_dirinfo.c
@@ -1,4 +1,4 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dirinfo.c,v 1.38 1996/06/04 19:04:41 sam Exp $ */
+/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dirinfo.c,v 1.40 1996/12/13 05:25:39 sam Exp $ */
 
 /*
  * Copyright (c) 1988-1996 Sam Leffler
@@ -166,7 +166,9 @@ static const TIFFFieldInfo tiffFieldInfo[] = {
     { TIFFTAG_INKSET,		 1, 1, TIFF_SHORT,	FIELD_INKSET,
       FALSE,	FALSE,	"InkSet" },
     { TIFFTAG_INKNAMES,		-1,-1, TIFF_ASCII,	FIELD_INKNAMES,
-      TRUE,	FALSE,	"InkNames" },
+      TRUE,	TRUE,	"InkNames" },
+    { TIFFTAG_NUMBEROFINKS,	 1, 1, TIFF_SHORT,	FIELD_NUMBEROFINKS,
+      TRUE,	FALSE,	"NumberOfInks" },
     { TIFFTAG_DOTRANGE,		 2, 2, TIFF_SHORT,	FIELD_DOTRANGE,
       FALSE,	FALSE,	"DotRange" },
     { TIFFTAG_DOTRANGE,		 2, 2, TIFF_BYTE,	FIELD_DOTRANGE,
@@ -214,6 +216,10 @@ static const TIFFFieldInfo tiffFieldInfo[] = {
     { TIFFTAG_TILEDEPTH,	 1, 1, TIFF_SHORT,	FIELD_TILEDEPTH,
       FALSE,	FALSE,	"TileDepth" },
 /* end SGI tags */
+#ifdef ICC_SUPPORT
+    { TIFFTAG_ICCPROFILE,	-1,-3, TIFF_UNDEFINED,	FIELD_ICCPROFILE,
+      FALSE,	TRUE,	"ICC Profile" },
+#endif
 };
 #define	N(a)	(sizeof (a) / sizeof (a[0]))
 
diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c
index 6fd3a66b..8d9cac55 100644
--- a/libtiff/tif_dirread.c
+++ b/libtiff/tif_dirread.c
@@ -1,4 +1,4 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dirread.c,v 1.71 1996/03/29 16:35:17 sam Exp $ */
+/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dirread.c,v 1.76 1997/02/10 20:18:43 sam Exp $ */
 
 /*
  * Copyright (c) 1988-1996 Sam Leffler
@@ -59,9 +59,7 @@ static	int TIFFFetchFloatArray(TIFF*, TIFFDirEntry*, float*);
 static	int TIFFFetchDoubleArray(TIFF*, TIFFDirEntry*, double*);
 static	int TIFFFetchAnyArray(TIFF*, TIFFDirEntry*, double*);
 static	int TIFFFetchShortPair(TIFF*, TIFFDirEntry*);
-#if STRIPCHOP_SUPPORT
 static	void ChopUpSingleUncompressedStrip(TIFF*);
-#endif
 
 static char *
 CheckMalloc(TIFF* tif, tsize_t n, const char* what)
@@ -100,8 +98,7 @@ TIFFReadDirectory(TIFF* tif)
 	/*
 	 * Cleanup any previous compression state.
 	 */
-	if (tif->tif_curdir != (tdir_t) -1)
-		(*tif->tif_cleanup)(tif);
+	(*tif->tif_cleanup)(tif);
 	tif->tif_curdir++;
 	nextdiroff = 0;
 	if (!isMapped(tif)) {
@@ -132,7 +129,7 @@ TIFFReadDirectory(TIFF* tif)
 	} else {
 		toff_t off = tif->tif_diroff;
 
-		if (off + sizeof (short) > tif->tif_size) {
+		if (off + sizeof (uint16) > tif->tif_size) {
 			TIFFError(tif->tif_name,
 			    "Can not read TIFF directory count");
 			return (0);
@@ -152,7 +149,7 @@ TIFFReadDirectory(TIFF* tif)
 			_TIFFmemcpy(dir, tif->tif_base + off,
 			    dircount*sizeof (TIFFDirEntry));
 		off += dircount* sizeof (TIFFDirEntry);
-		if (off + sizeof (uint32) < tif->tif_size)
+		if (off + sizeof (uint32) <= tif->tif_size)
 			_TIFFmemcpy(&nextdiroff, tif->tif_base+off, sizeof (uint32));
 	}
 	if (tif->tif_flags & TIFF_SWAB)
@@ -528,7 +525,6 @@ TIFFReadDirectory(TIFF* tif)
 	 */
 	if (!TIFFFieldSet(tif, FIELD_COMPRESSION))
 		TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
-#if STRIPCHOP_SUPPORT
         /*
          * Some manufacturers make life difficult by writing
 	 * large amounts of uncompressed data as a single strip.
@@ -538,11 +534,9 @@ TIFFReadDirectory(TIFF* tif)
 	 * side effect, however, is that the RowsPerStrip tag
 	 * value may be changed.
          */
-	if ((tif->tif_flags & TIFF_STRIPCHOP) &&
-	    td->td_nstrips == 1 && td->td_compression == COMPRESSION_NONE &&
-	    td->td_tilewidth == td->td_imagewidth)
+	if (td->td_nstrips == 1 && td->td_compression == COMPRESSION_NONE &&
+	    (tif->tif_flags & (TIFF_STRIPCHOP|TIFF_ISTILED)) == TIFF_STRIPCHOP)
 		ChopUpSingleUncompressedStrip(tif);
-#endif
 	/*
 	 * Reinitialize i/o since we are starting on a new directory.
 	 */
@@ -585,7 +579,9 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount)
 			if (cc > sizeof (uint32))
 				space += cc;
 		}
-		space = (filesize - space) / td->td_samplesperpixel;
+		space = filesize - space;
+		if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
+			space /= td->td_samplesperpixel;
 		for (i = 0; i < td->td_nstrips; i++)
 			td->td_stripbytecount[i] = space;
 		/*
@@ -601,7 +597,7 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount)
 			    filesize - td->td_stripoffset[i];
 	} else {
 		uint32 rowbytes = TIFFScanlineSize(tif);
-		uint32 rowsperstrip = td->td_imagelength / td->td_nstrips;
+		uint32 rowsperstrip = td->td_imagelength/td->td_stripsperimage;
 		for (i = 0; i < td->td_nstrips; i++)
 			td->td_stripbytecount[i] = rowbytes*rowsperstrip;
 	}
@@ -991,7 +987,7 @@ TIFFFetchAnyArray(TIFF* tif, TIFFDirEntry* dir, double* v)
 static int
 TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp)
 {
-	static char mesg[] = "to fetch tag value";
+	static const char mesg[] = "to fetch tag value";
 	int ok = 0;
 	const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, dp->tdir_tag);
 
@@ -1271,7 +1267,7 @@ TIFFFetchExtraSamples(TIFF* tif, TIFFDirEntry* dir)
 static int
 TIFFFetchRefBlackWhite(TIFF* tif, TIFFDirEntry* dir)
 {
-	static char mesg[] = "for \"ReferenceBlackWhite\" array";
+	static const char mesg[] = "for \"ReferenceBlackWhite\" array";
 	char* cp;
 	int ok;
 
@@ -1298,7 +1294,6 @@ TIFFFetchRefBlackWhite(TIFF* tif, TIFFDirEntry* dir)
 }
 #endif
 
-#if STRIPCHOP_SUPPORT
 /*
  * Replace a single strip (tile) of uncompressed data by
  * multiple strips (tiles), each approximately 8Kbytes.
@@ -1371,4 +1366,3 @@ ChopUpSingleUncompressedStrip(TIFF* tif)
 	td->td_stripbytecount = newcounts;
 	td->td_stripoffset = newoffsets;
 }
-#endif /* STRIPCHOP_SUPPORT */
diff --git a/libtiff/tif_dirwrite.c b/libtiff/tif_dirwrite.c
index 849cc11a..d177d6e0 100644
--- a/libtiff/tif_dirwrite.c
+++ b/libtiff/tif_dirwrite.c
@@ -1,4 +1,4 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dirwrite.c,v 1.56 1996/04/29 21:56:21 sam Exp $ */
+/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dirwrite.c,v 1.58 1997/01/15 19:01:24 sam Exp $ */
 
 /*
  * Copyright (c) 1988-1996 Sam Leffler
@@ -369,6 +369,7 @@ static int
 TIFFWriteNormalTag(TIFF* tif, TIFFDirEntry* dir, const TIFFFieldInfo* fip)
 {
 	u_short wc = (u_short) fip->field_writecount;
+	uint32 wc2;
 
 	dir->tdir_tag = fip->field_tag;
 	dir->tdir_type = (u_short) fip->field_type;
@@ -379,10 +380,9 @@ TIFFWriteNormalTag(TIFF* tif, TIFFDirEntry* dir, const TIFFFieldInfo* fip)
 	case TIFF_SSHORT:
 		if (wc > 1) {
 			uint16* wp;
-			if (wc == (u_short) TIFF_VARIABLE) {
+			if (wc == (u_short) TIFF_VARIABLE)
 				TIFFGetField(tif, fip->field_tag, &wc, &wp);
-				dir->tdir_count = wc;
-			} else
+			else
 				TIFFGetField(tif, fip->field_tag, &wp);
 			if (!WRITEF(TIFFWriteShortArray, wp))
 				return (0);
@@ -397,10 +397,9 @@ TIFFWriteNormalTag(TIFF* tif, TIFFDirEntry* dir, const TIFFFieldInfo* fip)
 	case TIFF_SLONG:
 		if (wc > 1) {
 			uint32* lp;
-			if (wc == (u_short) TIFF_VARIABLE) {
+			if (wc == (u_short) TIFF_VARIABLE)
 				TIFFGetField(tif, fip->field_tag, &wc, &lp);
-				dir->tdir_count = wc;
-			} else
+			else
 				TIFFGetField(tif, fip->field_tag, &lp);
 			if

(Patch may be truncated, please check the link at the top of this post.)