Convert multipage TIFF to PNG .Net

.net, multipage, png, tiff

Solution

You should select active frame (page) in a loop and convert each tiff page to a png.

int pageCount = 1;
try
{
    pageCount = bmp.GetFrameCount(FrameDimension.Page);
}
catch (Exception)
{
    // sometimes GDI+ throws internal exceptions.
    // just ignore them.
}

for (int page = 0; page < pageCount; page++)
{
    bmp.SelectActiveFrame(FrameDimension.Page, page);
    // save or otherwise process tiff page
}

This code assumes that you can load Tiff image in System.Drawing.Bitmap object.

Problem

I am able to convert a single page TIFF to a PNG in .Net, however, how would I do this for a multipage TIFF?

Original source