Splitting a Multi-page TIFF File (Visual Basic)
The following steps show how to loop through all pages of a multi-page TIFF file and extract each page, process it individually, and save it into a separate file.
1. |
Declare the following variables: |
Dim RasterIO As New LEADRasterIO
Dim rasterImage As New LEADRaster
Dim rasterProcess As New LEADRasterProcess
Dim nPageNumber As Integer
2. |
Find out the number of pages in the file: |
RasterIO.GetFileInfo rasterImage, "MultiPage.tif", 1, FILEINFO_TOTALPAGES
3. |
Loop through the pages of the file; perform a specific processing on the image, then save each page into a separate file: |
For nPageNumber = 1 To RasterIO.InfoTotalPages
' Load the next image in the loop
RasterIO.Load rasterImage, "MultiPage.tif",
0, nPageNumber, 1
' Perform desired processing on the page, such
as flipping it
rasterProcess.Flip rasterImage
' Save the page to a separate file
RasterIO.Save rasterImage, "PageNumber"
+ Format(nPageNumber, "0000") + ".tif", FILE_TIFLZW,
0, 0, SAVE_OVERWRITE
Next nPageNumber