This is the asp.net source for converting multi-page tiff file to one-page jpeg.
I used to MemoryStream class and then convert to the jpeg.
This is in Windows 2005, IIS6, Visual Studio 2008, and .NET Framework 2.0.
MemoryStream ms = null;
Image SrcImg = null;
Image returnImage = null;
try
{
SrcImg = Image.FromFile(@'d:\\test.tif');
ms = new MemoryStream();
FrameDimension FrDim = new FrameDimension(SrcImg.FrameDimensionsList[0]);
SrcImg.SelectActiveFrame(FrDim, 17); // 17 page...
SrcImg.Save(ms, ImageFormat.Tiff);
// Prevent using images internal thumbnail
SrcImg.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
SrcImg.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
//Save Aspect Ratio
if (SrcImg.Width <= ImgWidth) ImgWidth = SrcImg.Width;
int NewHeight = SrcImg.Height * ImgWidth / SrcImg.Width;
if (NewHeight > ImgHeight)
{
// Resize with height instead
ImgWidth = SrcImg.Width * ImgHeight / SrcImg.Height;
NewHeight = ImgHeight;
}
returnImage = Image.FromStream(ms).GetThumbnailImage(ImgWidth, NewHeight, null, IntPtr.Zero); }
but this code is well in Windows 2008, IIS7, Visual Studio 2010, and .NET Framework 4.0.
The Error eraise "SelectActiveFrame" sentence.
Here is the sample tiff file. [Mouse right click - Save as "test.tif"]
What's the matter? or Any good solution?