• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 412
  • Last Modified:

Extracting Tiff Frames in Dynamics AX

So I have a project I need some help with.  I need extract frames from Tiff images, most of them in pairs (fronts and backs of bank checks), and then save them as fileNameA.jpg and fileNameB.jpg for referencing front and back.

My problem lies in I need to call this code from AX so the solution has to be a .NET class/library.  Does anyone have any pointers, or what class to investigate?  Thanks for the help, feel free to ask any questions you have!
1 Solution
Bob LearnedCommented:
If you are working with multi-page TIFF files, then you need to look at the System.Drawing.Image class, and the FrameDimension (FrameDimensionsList) and SelectActiveFrame classes.

Here is an example:

TIFF Merge and Split Utility
public void ConvertToMultiPageTiff(List<string> fileNames, string outputFileName)
            ImageCodecInfo codecInfo = GetCodecInfo(TIFF_CODEC);
            EncoderParameters encoderParams = new EncoderParameters(2);
            encoderParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.SaveFlag, (long) EncoderValue.MultiFrame);
            encoderParams.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.Compression, ENCODING_SCHEME);
            Image image = Image.FromFile(fileNames[0]);
            if (!Directory.Exists(Path.GetDirectoryName(outputFileName)))
            image.Save(outputFileName, codecInfo, encoderParams);
            encoderParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.SaveFlag, (long)EncoderValue.FrameDimensionPage);
            FrameDimension frameDim = new FrameDimension(image.FrameDimensionsList[0]);
            for (int i = 1; i < image.GetFrameCount(frameDim); i++)
                image.SelectActiveFrame(frameDim, i);
                image.SaveAdd(image, encoderParams);
            Image[] images = new Image[fileNames.Count - 1];
            for (int i = 1; i < fileNames.Count; i++)
                images[i - 1] = Image.FromFile(fileNames[i]);
                frameDim = new FrameDimension(images[i - 1].FrameDimensionsList[0]);
                for (int j = 0; j < images[i - 1].GetFrameCount(frameDim); j++)
                    images[i - 1].SelectActiveFrame(frameDim, j);
                    image.SaveAdd(images[i - 1], encoderParams);

Open in new window


Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now