title: Separation of multipage tiff with compression "CCITT T.6" very slow
body: <p>I need to separate multiframe tiff files, and use the following method:</p>
  
  <pre><code>public static Image[] GetFrames(Image sourceImage)
  {
      Guid objGuid = sourceImage.FrameDimensionsList[0];
      FrameDimension objDimension = new FrameDimension(objGuid);
      int frameCount = sourceImage.GetFrameCount(objDimension);
      Image[] images = new Image[frameCount];
      for (int i = 0; i &lt; frameCount; i++)
      {
          MemoryStream ms = new MemoryStream();
          sourceImage.SelectActiveFrame(objDimension, i);
          sourceImage.Save(ms, ImageFormat.Tiff);
          images[i] = Image.FromStream(ms);
      }
      return images;
  }
  </code></pre>
  
  <p>It works fine, but if the source image was encoded using the CCITT T.6 compression, separating a 20-frame-file takes up to <strong>15 seconds</strong>  on my 2,5ghz CPU.(One core is at 100% during the process)</p>
  
  <p>When saving the images afterwards to a single file using standard compression (LZW), the separation time of the LZW-file is <strong>under 1 second</strong>.</p>
  
  <p>Saving with CCITT compression also takes very long.</p>
  
  <p>Is there a way to speed up the process?</p>
  
  <p>edit:</p>
  
  <p>I have measured the execution times:</p>
  
  <pre><code>        sourceImage.SelectActiveFrame(objDimension, i);
          sourceImage.Save(ms, ImageFormat.Tiff);
  </code></pre>
  
  <p>These two calls each account for around 50% of the total processing time.
  Using one MemoryStream with an initial capacity big enough for all images results in no measurable speed gain.
  The Image.FromStream method takes barely any processing time.</p>
  
  <p>I need the single frames because I need to process them(deskew, rotate, etc.).</p>
  
  <p>If there is a completely different method than mine, I would be happy to hear it.</p>