Last post Dec 08, 2008 07:11 AM by persa
Oct 02, 2008 07:15 AM|IanOSullivan|LINK
As mentioned I am having a problem converting a multipage tif to a mulitpage gif file. I am able to convert the tif file to gif but it loses any multipages. Single file pages are not a problem.
This is a simple version of the code I am using
Dim bm As Bitmap = Bitmap.FromFile("C:\S740368.tif")
Is it possible? I am using ASP.NET 2.0 but will be soon moving to 3.5. So is it perhaps possible with 3.5?
convert multipage tif to mulitpage gif
Oct 06, 2008 10:30 AM|persa|LINK
I think you should have a look at the SelectActiveFrame and SaveAdd methods of the Image class in System.Drawing.Image.
By using SelectActiveFrame in a loop you should be able to step through the pages of the input tiff and use SaveAdd to add them to the new output file.
Oct 09, 2008 05:39 AM|IanOSullivan|LINK
Thanks Persa. I'll try that and let you know how I get on.
Dec 08, 2008 04:41 AM|IanOSullivan|LINK
I've tried as you suggested and got very close to what I want to achieve. But I am still having problems with the SaveAdd fucntion below. I get an error stating:
'An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in system.drawing.dll
Additional information: A generic error occurred in GDI+.'
I am able to loop through the tif image pages and save these as individual gif images by uncommenting the mygif.Save("c:\test_" & i & ".gif")
line below. But my problem still remains that I cannot create a mulit-page gif image.
Am I perhaps using the SaveAdd function incorrectly? Do I need to add a reference?
Here is my code
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim enc As Encoder = Encoder.SaveFlag
Dim encparam As New EncoderParameter(enc, Long.Parse(EncoderValue.MultiFrame))
Dim encparams As EncoderParameters = New EncoderParameters(1)
encparams.Param(0) = encparam
Dim mygif As Image = Image.FromFile("c:\test.tif")
For i As Integer = 1 To mygif.GetFrameCount(FrameDimension.Page) - 1
'mygif.Save("c:\test_" & i & ".gif")
Dec 08, 2008 07:11 AM|persa|LINK
I am sorry but a little more investigation gives that the GDI+ GIF encoder used can't create multiframe GIF images...
So I think you need some graphics toolkit with more advanced GIF functionality. One possibility is GifLib, have a look at