•  
  •  
  •  
 

Trying to append images into a new tiff image file

  •  26 Nov 2008, 10:29 AM

    Trying to append images into a new tiff image file

     I am trying to the follwing, create a console application that opens an existing tiff file a page at a time(if I load any tiff greater than 32mb I get a pixel memory error) and then rencode each page and then save back into a new tiff file(our Adobe capture server doesn't like the original file).  I can open the existing file a page at a time using the workspace object, but am having difficulty with the appending each page back into a new file, using the workspace.save supposedly will append, but all I get is the last page.  I have also tried using filestreams with no luck.  Here is my current code.   Any help would greatly be appreciated.

    Dim wsv As Workspace = New Workspace

    Dim decoder As TiffDecoder = New TiffDecoder

    Dim Pagecount, i As Integer

    Try

    ' Add trailing separators to the supplied paths if they don't exist.

    If Not args(0).EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()) Then

    args(0) &= System.IO.Path.DirectorySeparatorChar

    End If

    ' Add trailing separators to the supplied paths if they don't exist.

    If Not args(1).EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()) Then

    args(1) &= System.IO.Path.DirectorySeparatorChar

    End If

    Console.WriteLine("Opening file " & args(2))

    Dim fsin As FileStream = New FileStream(args(0) & args(2), FileMode.Open, FileAccess.Read, FileShare.Read)

    Console.WriteLine("Opened file " & args(2) & " successfully.")

    Dim enc As TiffEncoder = New TiffEncoder(TiffCompression.Default)

    ' Add trailing separators to the supplied paths if they don't exist.

    If Not args(1).EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()) Then

    args(1) &= System.IO.Path.DirectorySeparatorChar

    End If

    Console.WriteLine("opening " & args(2) & "...")

    Pagecount = decoder.GetFrameCount(fsin)

    fsin.Close()

    For i = 0 To Pagecount - 1

    wsv.Open(args(0) & args(2), i)

    Console.WriteLine("Opened page " & i + 1 & " to " & Pagecount)

    wsv.Save(args(1) & args(2), enc)

    Console.WriteLine("Uncompressed page " & i + 1 & " to " & Pagecount)

    Next

    Console.WriteLine("Uncompressed file " & args(2) & " successfully.")

    enc = Nothing

    Catch ex As Exception

    Console.WriteLine(ex.Message)

    End Try

    Filed under: , ,
View Complete Thread