multipage tiff with image rotation problem

Discussions about image processing and document imaging.
Post Reply
steves
Posts: 59
Joined: Fri Oct 17, 2008 4:38 pm

multipage tiff with image rotation problem

Post by steves » Thu Oct 22, 2009 12:03 pm

Hi Loic,

Got a strange problem for you.

im using the code below to save out a multipage tif to seperate files using the following code.

Code: Select all

        nImageID = image.CreateGdPictureImageFromFile("")
        For i As Integer = 1 To image.TiffGetPageCount(nImageID)
            image.TiffSelectPage(nImageID, i)
            image.SaveAsTIFF(nImageID, "c:\page" & Str(i) & ".tif", GdPicture.TiffCompression.TiffCompressionCCITT4)
        Next i
        image.ReleaseGdPictureImage(nImageID)
This works correctly get all 3 pages as seperate files however i need to rotate the image first before saving so i use the following code

Code: Select all

        nImageID = image.CreateGdPictureImageFromFile("")
        For i As Integer = 1 To image.TiffGetPageCount(nImageID)
            image.TiffSelectPage(nImageID, i)
                 If i = 1 Then
                      image.Rotate(nImageID, Drawing.RotateFlipType.Rotate90FlipNone)
                End If
            image.SaveAsTIFF(nImageID, "c:\page" & Str(i) & ".tif", GdPicture.TiffCompression.TiffCompressionCCITT4)
        Next i
        image.ReleaseGdPictureImage(nImageID)
I would expect this code to load the image select the first page,rotate the image 90 and save the page.
Yes this works for the 1st page but when i select the next page it skips the rotation as expected and saves page 2,but page 2 it saves it page 1.
And this continues to i have 5 pages of page 1 even though i am moving to the next page each time

Im confused to why this is happeneing maybe you can shed some light on this.

Thanks
Steve

steves
Posts: 59
Joined: Fri Oct 17, 2008 4:38 pm

Re: multipage tiff with image rotation problem

Post by steves » Thu Oct 22, 2009 12:19 pm

Further to my post above as soon as i rotate the image i get retuned Object.UnsupportedImageFormat{22} even though the image is ok when not rotated.

Also have the same problem when trying to deskew the image as well same error code returned Object.UnsupportedImageFormat{22}.

Looks like something strange is happeneing during the image processing and the image is no longer being recognised as a multipage tiff

Thanks
Steve

steves
Posts: 59
Joined: Fri Oct 17, 2008 4:38 pm

Re: multipage tiff with image rotation problem

Post by steves » Thu Oct 22, 2009 1:01 pm

Cant draw a rectangle on the image either same problem as above.

Thanks
Steve

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: multipage tiff with image rotation problem

Post by Loïc » Thu Oct 22, 2009 4:12 pm

Steve, you need to open the multipage tiff for read & write before creating the GdPicture image:

Code: Select all

image.TiffOpenMultiPageForWrite(True)
Kind regards,

Loïc

steves
Posts: 59
Joined: Fri Oct 17, 2008 4:38 pm

Re: multipage tiff with image rotation problem

Post by steves » Thu Oct 22, 2009 4:55 pm

How Embarrasing :oops:

Thats solved it.Thanks Loic

Cheers
steve

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: multipage tiff with image rotation problem

Post by Loïc » Thu Oct 22, 2009 5:13 pm

You are Welcome Steve :)

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests