How do I save a page out of a TIFF upside down?

I have been trying to see why the code below will not save a page out of a TIFF rotated 180 degrees?

I am using VS.NET 2005

Code that I am testing with:

            Dim mImage As Image = Image.FromFile(mPath)
            Dim mPageCount As Integer = mImage.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page)

            dstPath = System.Configuration.ConfigurationSettings.AppSettings.Get("DestinationPath")
            dstPath = dstPath & Mid(My.Computer.FileSystem.GetName(mPath), 1, Len(My.Computer.FileSystem.GetName(mPath)) - 4) & "\"
            For i As Integer = 0 To mPageCount - 1
                Dim mOldFileName As String = String.Empty
                Dim mUpsideDown  As String = String.Empty
                mImage.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, i)
                mOldFileName = dstPath & i & ".tif"
                mUpsideDown = dstPath & i & "_Flipped.tif"
                mImage.Save(mUpsideDown )

What the code does do is save each page in the same orinentation, so I get a file named:

But both files are the same way up.

Am I missing a step?

Thanks in advanced
Who is Participating?
I had some code that deletes a page from tiff. that uses EncoderParameters.
I think thats the part you are missing for the RotateFlip.
Just change the code to save your new tiff that is rotated.

Imports System.IO
Imports System
Imports System.Drawing
Imports System.Drawing.Imaging

Public Class DeleteAtiff_page
    Dim myImageCodecInfo As ImageCodecInfo
    Dim myEncoder As Encoder
    Dim myEncoderParameter As EncoderParameter
    Dim myEncoderParameters As EncoderParameters
    Function RemoveFirstPage(ByVal file As String) As Stream
        Dim fName As String = file.Substring(file.LastIndexOf("\"))
        Dim tFile As String = "C:\" & fName & ".temp.tif"
        Dim newFileName As String = "C:\" & fName
        Dim Dimension As System.Drawing.Imaging.FrameDimension
        Dim tiffImage As Image = Image.FromFile(file)
        Dimension = New System.Drawing.Imaging.FrameDimension(tiffImage.FrameDimensionsList(0))
        tiffImage.SelectActiveFrame(Dimension, 1)
        Dim pageCount As Integer = tiffImage.GetFrameCount(Dimension)
        Dim newTiff As Image = Image.FromFile(tFile)
        Dim encSave = New Imaging.Encoder(Imaging.Encoder.SaveFlag.Guid)
        Dim encParamsCompress = New Imaging.EncoderParameters(1)
        Dim encParamsMulti = New Imaging.EncoderParameters(2)
        Dim encParamsAddFrame = New Imaging.EncoderParameters(1)
        Dim encParamsCloseFrame = New Imaging.EncoderParameters(1)
        Dim encCompress = New Imaging.Encoder(Imaging.Encoder.Compression.Guid)
        encParamsCloseFrame.Param(0) = New Imaging.EncoderParameter(encSave, Imaging.EncoderValue.Flush)
        encParamsCompress.Param(0) = New Imaging.EncoderParameter(encCompress, Imaging.EncoderValue.CompressionLZW)
        encParamsMulti.Param(0) = New Imaging.EncoderParameter(encCompress, Imaging.EncoderValue.CompressionLZW)
        encParamsMulti.Param(1) = New Imaging.EncoderParameter(encSave, Imaging.EncoderValue.MultiFrame)
        encParamsAddFrame.Param(0) = New Imaging.EncoderParameter(encSave, Imaging.EncoderValue.FrameDimensionPage)
        encParamsCloseFrame.Param(0) = New Imaging.EncoderParameter(encSave, Imaging.EncoderValue.Flush)
        newTiff.Save(newFileName, GetCodecInfo(Imaging.ImageFormat.Tiff), encParamsMulti)
        For i As Integer = 2 To pageCount - 1
            tiffImage.SelectActiveFrame(Dimension, i)
            newTiff.SaveAdd(tiffImage, encParamsAddFrame)
        IO.File.Copy(newFileName, file, True)
        Return New IO.FileStream(file, FileMode.Open)
    End Function
    Private Shared Function GetCodecInfo(ByVal format As Imaging.ImageFormat) As Imaging.ImageCodecInfo
        Dim codecs() As Imaging.ImageCodecInfo
        Dim codec As Imaging.ImageCodecInfo
        Dim clsid As Guid
        Dim i As Integer
        clsid = format.Guid
        codecs = Imaging.ImageCodecInfo.GetImageEncoders()
        For Each codec In codecs
            If clsid.Equals(codec.FormatID) Then Return codec
    End Function
End Class
ttkachukAuthor Commented:
Tweaking that up - that seem to work -
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.