Welcome Guest! To enable all features, please Login or Register.



Last Go to last post Unread Go to first unread post
#1 Posted : Wednesday, March 15, 2006 7:59:13 PM(UTC)


Groups: Registered
Posts: 22

Hello all,
I'm using 12.1 (soon to upgrade to .NET version).
I use code to create a multi page tiff as follows.
(In TwainPage event)
'if the current multipage file doesnt exist
If Not FileExists(Me.MultiPageFileName) Then
   m_objTWAIN.Save Me.MultiPageFileName, FILE_TIFLZW, 0, 0, SAVE_OVERWRITE
   'otherwise the file exists.
   'append the bitmap to the file
   m_objTWAIN.Save Me.MultiPageFileName, FILE_TIFLZW, 0, 0, SAVE_APPEND
end if
The code above creates the multi page tiff perfectly... I can view it in windows viewer and everything, however
if I try to modify a page in the tiff and resave, the file size jumps... with every save.. no matter what page I add..
m_objLEADControl.Load Me.Path, 0, 1, -1
m_objLEADControl.SavePage = 1
m_objLEADControl.Save Me.Path, FILE_TIFLZW, 0, 0, SAVE_REPLACE
This code makes the tiff file size jump every time though I can still view the image in the windows viewer.  Can someone give me any clue as to what may be going wrong?
Replacing a page with the same page should not increase the file size over and over again. 
Thanks in advance to all replies.
Bryan James.

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Sunday, March 19, 2006 3:41:39 AM(UTC)


Groups: Manager, Tech Support
Posts: 367


When you delete or replace a page from a TIFF file, the standard behavior is to mark the page as deleted in the file without removing the space used by it. This means the file is not 'compacted' during Delete or Replace operations.

What you could do is to load only the pages you want to stay in the file and save them to a temporary file name. When you're finished putting all the needed pages in the temporary file, delete the original and rename the temporary with its name.

In particular, Raster Imaging Pro and above toolkits contain a new function in LEADTOOLS 14.5 and later called CompactFile, which can automatically take a partial set of pages from one file and put them in a different file (new or existing) without changing their contents.

If you would like considering upgrading to the latest version, I recommend downloading the free evaluation edition and trying it.

Edited by user Thursday, October 6, 2016 10:55:19 AM(UTC)  | Reason: Not specified

Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
#3 Posted : Monday, April 10, 2006 7:08:33 PM(UTC)


Groups: Registered
Posts: 22


We've purchased 14.5 with support and I like the new functionality.

Could you point me to an example of the CompactFile functionality?





#4 Posted : Monday, April 10, 2006 7:51:02 PM(UTC)


Groups: Registered
Posts: 22

I found the solution on my own and figured I'd share..

I have a method that encapsulates the LEAD Save functionality

Here is the new code

'if the temporary tiff file exists

If FileExists(Filename & "." & dvAnnotationExtension & "." & "tmp") Then
               'get red of it
               DeleteFile (Filename & "." & dvAnnotationExtension & "." & "tmp")
            End If
            Dim RasterIO As New LeadRasterIO

            Dim nRet As Integer
            ' This example will compact all the pages in a TIFF file. It will create a new file called dstfile.tif
            nRet = RasterIO.CompactFile(Filename, Filename & "." & dvAnnotationExtension & "." & "tmp", 0, 0, -1, SAVE_OVERWRITE, 0)
            If nRet <> 0 Then
               MsgBox "Error compacting file!"
               Dim objFSO As FileSystemObject
               Set objFSO = New FileSystemObject
               DeleteFile Filename
               objFSO.MoveFile Filename & "." & dvAnnotationExtension & "." & "tmp", Filename
               Set objFSO = Nothing
            End If
            'LEAD.Save fileName, intFileFormat, 0, intQuality, SAVE_REPLACE
            Set RasterIO = Nothing

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2023, Yet Another Forum.NET
This page was generated in 0.088 seconds.