Extracting Tiff Frames in Dynamics AX

Posted on 2011-10-25
Last Modified: 2012-05-12
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!
Question by:aswitalski
    1 Comment
    LVL 96

    Accepted Solution

    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now