title: Tiff file compression with C#
body: <p>I have a tiff file which during original creation and saving has compression type "LZW".</p>
  
  <pre><code>System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(800, 1000); 
  Graphics g = Graphics.FromImage(bitmap);
  fileName = saveDirectory + id + ".tif";
  bitmap.Save(fileName, ImageFormat.Tiff);
  </code></pre>
  
  <p>So I am trying to change its compression to CCIT:-</p>
  
  <pre><code>Bitmap myBitmap;
  myBitmap = new Bitmap(fileName);
  ImageCodecInfo myImageCodecInfo;
  myImageCodecInfo = GetEncoderInfo("image/tiff");
  System.Drawing.Imaging.Encoder myEncoder;
  myEncoder = System.Drawing.Imaging.Encoder.Compression;
  EncoderParameters myEncoderParameters;
  myEncoderParameters = new EncoderParameters(1);
  EncoderParameter myEncoderParameter;      
  myEncoderParameter = new EncoderParameter(myEncoder,(long)EncoderValue.CompressionCCITT4);
  myEncoderParameters.Param[0] = myEncoderParameter;
  myBitmap.Save(new_fileName);
  
      private static ImageCodecInfo GetEncoderInfo(String mimeType)
      {
        int j;
        ImageCodecInfo[] encoders;
        encoders = ImageCodecInfo.GetImageEncoders();
        for (j = 0; j &lt; encoders.Length; ++j)
          {
              if (encoders[j].MimeType == mimeType)
              return encoders[j];
          }
        return null;
      }
  </code></pre>
  
  <p>However, after running through the process, my file properties still says that it is of the "LZW compression" type.</p>
  
  <p>Can anyone explain to me where I am going wrong with this?</p>