gif to tiff with compression

VBAHole22

Well-known member
Joined
Oct 21, 2003
Messages
432
Location
VA
I have a simple routine that converts gif images to tiffs like so

Code:
If fi.Name.Substring(fi.Name.Length - 4, 4).ToUpper = ".GIF" Then
                    Dim img As Image = Image.FromFile(fi.FullName)
                    Dim tifName As String
                    tifName = Path.GetDirectoryName(fi.FullName)
                    tifName = tifName & "\" & Path.GetFileNameWithoutExtension(fi.Name) & ".tif"
                    img.Save(tifName, ImageFormat.Tiff)
                    i += 1
                    Me.txtResults.Text = Me.txtResults.Text & System.Environment.NewLine & i & " Saved " & tifName
                Else
                    MessageBox.Show("Something is messed up this is not a gif file")
                End If

Really very simple.

But is there a way that I can control the compression of the tiff that results?
I have tried looking into the EncoderParameters but there is scare info out there about this stuff.
Any suggestions?
 
Yeah, I have come across that site during my searches.
He does have a routine for JPEG compression but not gif or tiff.
He uses the EncoderParameters and literal strings like

codec.MimeType=="image/jpeg")

Im wondering where this stuff is cataloged? How does one find out about the collections and how to use them?
 
Doing a search on "tiff compression EncoderParameter" in Google turned up a number of good hits. No direct sample code to do exactly what you want, but very close (including getting the parameters needed for each mime type when using the EncoderParameter object).

-ner
 
Okay, I made small progress on this one. I managed to get the encoder parameters working for LZW and No Compression but there are other options (CCIT3, CCIT4, RLE). None of these options will work for me. They all throw errors. Whats up with that?

I would like to use RLE but cant figure out how.

I am also interested in doing gif to tif with no compression but I want to reduce the colors from 256 to 16. Anyone know how to do that?

I gotta say, working with images like this in .NET is not fun or easy. Why is it so complicated and how come there is so little code out there? Is everyone just using photoshop or some 3rd party tool? Can you program those to run batch?

Any suggestions will be greatly appreciated.
 
Back
Top