Below I wrote a simple app that take an image (tif) file and rotates it (in this case 180 degrees) and saves it back out, which was my goal for this proof of concept. However, in order for the saved image to be in the same compression as the original I had to use the "EncoderParameter" and specify the compression, which in this case was CCITT4(Fax Group 4). My question is there a way to detect the compression from the original image? because not all our images we store are compressed in CCITT4.
VB.NET:
Dim image As Bitmap
Dim eps As Imaging.EncoderParameters = New Imaging.EncoderParameters(1)
image = image.FromFile("C:\tiff\Page04.tif", True)
image.RotateFlip(RotateFlipType.Rotate180FlipNone)
Dim CodecInfo() As System.Drawing.Imaging.ImageCodecInfo
Dim TifCodec As System.Drawing.Imaging.ImageCodecInfo
CodecInfo = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders
TifCodec = CodecInfo(3)
eps.Param(0) = New Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Compression, _
System.Drawing.Imaging.EncoderValue.CompressionCCITT4)
image.Save("C:\tiff\fliptest11.tif", TifCodec, eps)