[Last Call] Learn how to a build a cloud-first strategyRegister Now


Multipage TIff Image Convert to Single page Gif

Posted on 2009-02-23
Medium Priority
Last Modified: 2013-11-26
Hi, I need to write an application in Vb.net that take all existing tiff files and convert them into Gif so they can viewable by our website.  Here are two main requirements.  Any code would help.

1. We can't buy third party control/Application
2. Each Tiff image are Multiple Pages, So each page of the tiff must be saved as a gif.
Question by:vb7guy
1 Comment
LVL 96

Accepted Solution

Bob Learned earned 1500 total points
ID: 23721761
You could start with this, and see if you can find a way:

Imports System
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.IO
Public Class TiffImage
    Public Sub New(ByVal fileName As String)
        _fileName = fileName
    End Sub
    Private _fileName As String
    Public ReadOnly Property FileName() As String
            Return _fileName
        End Get
    End Property
    Public ReadOnly Property PageCount() As Integer
            ' Get the frame dimension list from the image of the file and 
            Dim image As Image = Image.FromFile(FileName)
            ' Get the globally unique identifier (GUID) 
            Dim objGuid As Guid = image.FrameDimensionsList(0)
            ' Create the frame dimension 
            Dim frameDimension As New FrameDimension(objGuid)
            'Gets the total number of frames in the .tiff file 
            Return image.GetFrameCount(frameDimension)
        End Get
    End Property
    ' Return the memory stream of a specific page 
    Public Function GetTiffSpecificPage(ByVal pageNumber As Integer) As Image
        Dim image As Image = Image.FromFile(Me.FileName)
        Using ms As New MemoryStream()
            Dim objGuid As Guid = image.FrameDimensionsList(0)
            Dim objDimension As New FrameDimension(objGuid)
            image.SelectActiveFrame(objDimension, pageNumber)
            image.Save(ms, ImageFormat.Bmp)
            Dim retImage As Image = Image.FromStream(ms)
            Return retImage
        End Using
    End Function
End Class

Open in new window


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question