Page 1 of 1

Append to a Multipage Tiff

Posted: Mon Oct 08, 2007 10:07 pm
by jaswicki
Is there a way to insert a new scanned page into a multipage TIF at a particular page number rather than to the end, such as adding a cover page to an existing multipage tiff? Or if not is there a way to merge 2 or more Tiffs?


[Update by Loïc Carrère]. See: viewtopic.php?t=395

Posted: Wed Oct 10, 2007 4:44 pm
by Loïc
[Update by Loïc Carrère]. Deprecated post. See: viewtopic.php?t=395








Hi,

To write to on an existing multipage tif image you need:

- Extract all the pages into temporary image files.

Code: Select all

Imaging1.CreateImageFromFile sMultiPageTiffPath

nImageID = Imaging1.CreateImageFromFile("inputmultipage.tif")
nPageCount = Imaging1.TiffGetPageCount 
 
For nCpt = 1 To nPageCount 
     Imaging1.TiffSelectPage (nCpt)
     Imaging1.SaveAsTiff (Str(nCpt) & ".tif")
Next nCpt

Imaging1.CloseNativeImage
- Recompose new multi page tif file from the temporary files.

Code: Select all

nImageID = Imaging1.CreateImageFromFile("1.tif")
Imaging1.TiffSaveAsNativeMultiPage ("outputmultipage.tif")
  
For nCpt = 2 To nPageCount 
    nImageID = Imaging1.CreateImageFromFile(str(nCpt) & ".tif")
    Imaging1.TiffAddToNativeMultipage (nImageID)
    Imaging1.CloseImage (nImageID)
next nCpt  

'Here add your new image, ex Imaging1.TiffAddToNativeMultipage (nNewImageID)

Imaging1.TiffCloseNativeMultiPage

However, for the next release I will add a method to merge two tif files.

Best regards,

Loïc Carrère

Posted: Fri Oct 19, 2007 2:19 pm
by jaswicki
Thanks!