Return-Path: <tiff-bounces@lists.maptools.org>
Received: from inas024.isp.belgacom.be (localhost [127.0.0.1])
        by inav008.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-AV-3.00) with ESMTP id j73HDQvr016321
        for <joris.at.lebbeke@skynet.be>; Wed, 3 Aug 2005 19:13:26 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from inmx001.isp.belgacom.be (inmx001.isp.belgacom.be [195.238.2.1])
        by inas024.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-AS-2.03) with ESMTP id j73HDNtX016122
        for <joris.at.lebbeke@skynet.be>; Wed, 3 Aug 2005 19:13:24 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (r153.dmsolutions.ca [209.217.116.153] (may be forged))
        by inmx001.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-2.32) with ESMTP id j73HDLIN011998
        for <joris.at.lebbeke@skynet.be>; Wed, 3 Aug 2005 19:13:22 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (duke.maptools.org [127.0.0.1])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id j73H54Sa029920;
	Wed, 3 Aug 2005 13:05:46 -0400
Received: from fwall2.konicabt.com (fwall2.konicabt.com [63.172.69.188])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id j73H501w029910
	for <tiff@lists.maptools.org>; Wed, 3 Aug 2005 13:05:00 -0400
Received: from konicabt.com by fwall2.konicabt.com;
	Wed, 03 Aug 2005 16:40:42 GMT
Received: from dcabrames (dcabrames.konicabt.com [10.5.4.130])
	by konicabt.com (8.13.1/8.13.1) with SMTP id j73H4w2g017598
	for <tiff@lists.maptools.org>; Wed, 3 Aug 2005 13:04:58 -0400
From: "David Abrames" <abramesd@kmbs.konicaminolta.us>
To: <tiff@lists.maptools.org>
Subject: Re: [Tiff] Unable to read TIFF Directory
Date: Wed, 3 Aug 2005 13:02:29 -0400
Message-ID: <NFBBIEOMGLCCHGNLFIPLIEAOBCAB.abramesd@konicabt.com>
MIME-Version: 1.0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0)
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
In-Reply-To: <200508031528.j73FSDnZ028194@duke.maptools.org>
Importance: Normal
X-Blade-MailScanner-Information: Please contact support@kmbs.konicaminolta.us
	for more information
X-Blade-MailScanner: Found to be clean
X-Blade-MailScanner-SpamCheck: not spam (whitelisted),
	SpamAssassin (score=0.103, required 5, autolearn=disabled, AWL 0.10)
X-MailScanner-From: abramesd@konicabt.com
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.4
Precedence: list
Reply-To: abramesd@kmbs.konicaminolta.us
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/pipermail/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=subscribe>
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org
X-UIDL: 000000000023ceae.00000a08
X-MSP-STORE: Wed, 03 Aug 2005 19:13:35 +0200
Status:   

> On Tue, Aug 02, 2005 at 06:39:16PM -0400, David Abrames wrote:
> > I am getting the following error when I call the TIFFReadDirectory
> > function:
> >
> > *** TIFF ERROR in module: INTERNAL: No space to read TIFF directory.
> >
> > This seems to be the result of a failure to allocate memory from a
> > call to TIFFMalloc.  The problem is as far as I can determine I have
> > more than enough memory available as other calls to malloc work OK in
> > the program that is calling the libtiff functions.
> >
> > What I am doing is reading one multi-directory tiff file, updating the
> > directory image and then creating a new directory and writing it to a
> > new multi-directory tiff file..  The first directory is processed OK
> > and I get a new tiff file with the one directory init.  However the
> > loop that is processing the tiff file is unable to read the next
> > directory and produces the above error message.
> >
> > Is there a TIFF function I need to call before calling
> > TIFFReadDirectory to release the previous directory?  I also tried
> > TIFFSetDirectory and get the same results.  Any suggestions would be
> > appreciated.
>
> You should use TIFFWriteDirectory() before switching to the next IFD. If
> you want open partially written file use  TIFFCheckpointDirectory()
> instead.
>
> Regards,
> Andrey
>
> --
> Andrey V. Kiselev
> Home phone:  +7 812 5970603  ICQ# 26871517
>

Dear Andrey,

Thank you for your reply.  Sorry I was not clear but I am calling
TIFFWriteDirectory prior to calling TIFFReadDirectory.  Here is a sample of
what I am doing...

inTIFF = TIFFOpen("myTIFFfile", "r");
outTiff = TIFFOpen(myNewTiff", "w");

do
{
  getTIFFInfo(inTiff);   // reads the directory tags

  setTIFFInfo(outTiff);  // sets the directory tags
                         // from previous function

  image = getBitMap(inTiff);  // uses TIFFReadEncodedStrip
                              // to build a bitmap image

  processImage(image);  // processes the image

  createStrips(outTiff, image);  // uses TIFFWriteEncodedStrip
                                 // to convert bitmap into strips
                                 // in the new directory of the
                                 // output tiff file

  TIFFWriteDirectory(outTiff);

} while(TIFFReadDirectory(inTiff));

TIFFClose(inTiff);
TIFFClose(outTiff);

The error message is caused by the call to TIFFReadDirectory in the while
statement.  Like I said I am getting the first directory (page) in the
output tiff file and it is processed as I expect so the code is working up
to the point where I try and get the next directory.  I tried changing the
TIFFReadDirectory to a TIFFSetDirectory and this produces the same error.  I
also tried to call malloc after the do-while loop and was able to allocate
1MB of memory successfully so I don't understand why libtiff thinks there is
no space.  I am sure I am missing something but I can't figure out what.

David

_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
