title: Merging multiple TIFF files in one TIFF file
body: <p>I've been trying to use the mergeTiffStreams method of the TiffUtil class posted at:</p>
  
  <p><a href="http://kseesharp.blogspot.com/2007/12/class-for-tiff-manipulation.html" rel="nofollow">http://kseesharp.blogspot.com/2007/12/class-for-tiff-manipulation.html</a></p>
  
  <p>However, like other people have commented on that thread, the end result is that I receive a Stream that only contains my first TIFF file.  The other TIFFs that I passed in the MemoryStream array are not included.</p>
  
  <p>Has anyone else run into this problem before?  If so, any advice would be most appreciated.</p>
  
  <p>Thanks.</p>
  
  <p>[UPDATE]</p>
  
  <p>Here's the code I have at the moment.  The stream that it returns only contains the first TIFF from the array passed in.</p>
  
  <pre><code>    public MemoryStream mergeTiffStreams(MemoryStream[] tiffStreams)
      {
          if (tiffStreams == null)
              throw new ArgumentNullException("tiffStreams");
  
          Encoder enc = Encoder.SaveFlag;
  
          ImageCodecInfo info = null;
          foreach (ImageCodecInfo ice in ImageCodecInfo.GetImageEncoders())
              if (ice.MimeType == "image/tiff")
                  info = ice;
  
          EncoderParameters ep = new EncoderParameters(1);
          ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.MultiFrame);
          MemoryStream tiffStream = new MemoryStream();
          Bitmap masterBitmap = new Bitmap(tiffStreams[0]);
          masterBitmap.Save(tiffStream, info, ep);
  
          ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.FrameDimensionPage);
          for (int x = 1; x &lt; tiffStreams.Length; x++)
          {
              masterBitmap.SaveAdd(Image.FromStream(tiffStreams[x]), ep);
          }
  
          ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.Flush);
          masterBitmap.SaveAdd(ep);
  
          return tiffStream;
      }
  </code></pre>