Skip to content

Instantly share code, notes, and snippets.

@pedroinfo
Created January 9, 2017 16:22
Show Gist options
  • Save pedroinfo/534030be611a7dd0066bc9844850ce8e to your computer and use it in GitHub Desktop.
Save pedroinfo/534030be611a7dd0066bc9844850ce8e to your computer and use it in GitHub Desktop.
split tiff multipage c# - Example
public class Program
{
public static void Main(string[] args)
{
SplitTiff(@"c:\temp\0001.tif");
Console.Read();
}
public static void SplitTiff(string filepath)
{
int activePage;
int pages;
var dest = @"c:\temp";
Image image = Image.FromFile(filepath);
pages = image.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page);
for (int index = 0; index < pages; index++)
{
activePage = index + 1;
image.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, index);
image.Save(dest + @"\file_" + activePage.ToString() + ".tif", System.Drawing.Imaging.ImageFormat.Tiff);
}
image.Dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment