Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How can I append multipage TIFF images to 1 file using C#?

How can I append multipage TIFF images to 1 file using C#?

How can I append multipage TIFF images to 1 file using C#?

I use the following code to create a multipage TIFF image.

It works fine for the creation of 1 multipage TIFF image.

Could you show me how I can modify this code so that everytime I call the MergeTwoImages function and pass it a new set of 2 more images (firstimage and secondimage), that they are appended to the outputImage?

I would like to create many multipage TIFF images into 1 file.


Byte[] img = bytes.Skip(irecpositionrevised + irectypelength).Take(intpos1revised).ToArray();

Byte[] img1 = bytes.Skip(irecpositionrevised + irectypelength + intpos1revised).Take(intpos2revised).ToArray();

System.Drawing.Bitmap newImage = MergeTwoImages(ConvertFromByteArray(img), ConvertFromByteArray(img1));


private static Image ConvertFromByteArray(byte[] input)
using (var ms = new MemoryStream(input))
return Image.FromStream(ms);

public static Bitmap MergeTwoImages(Image firstImage, Image secondImage)
if (firstImage == null)
throw new ArgumentNullException("firstImage");

if (secondImage == null)
throw new ArgumentNullException("secondImage");

int outputImageWidth = firstImage.Width > secondImage.Width ? firstImage.Width : secondImage.Width;

int outputImageHeight = firstImage.Height + secondImage.Height + 1;

Bitmap outputImage = new Bitmap(outputImageWidth, outputImageHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

using (Graphics graphics = Graphics.FromImage(outputImage))
graphics.DrawImage(firstImage, new Rectangle(new Point(), firstImage.Size),
new Rectangle(new Point(), firstImage.Size), GraphicsUnit.Pixel);
graphics.DrawImage(secondImage, new Rectangle(new Point(0, firstImage.Height + 1), secondImage.Size),
new Rectangle(new Point(), secondImage.Size), GraphicsUnit.Pixel);

return outputImage;

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close