Error processing SSI file
LEADTOOLS

Show in webframe

Some multipage file formats (including DICOM, PDF, Jp2, among others), become quite slow to load or convert when they have a lot of pages. That is because to get to page N you sometimes have to go through pages 1, 2, ... N-1 before you get to page N. For such formats, very often loading page N becomes slower and slower as N increases.

LEADTOOLS provides a mechanism for speeding up the loading or conversion of such files.

To use this mechanism, perform something like the following steps:

  1. Call the StartOptimizedLoad function.
  2. Create a loop from the same source file.
  3. In the loop, call one of the codecs.Load functions, passing the name of the source file.
  4. Perform any processing on the section that was loaded.
  5. When finished, call the StopOptimizedLoad function.

Example:

public void OptimizedLoadExample()
{
    using (RasterCodecs codecs = new RasterCodecs())
    {
       // The speed improvement is most noticeable in source files with many pages
       string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "MultiPage.pdf");

       // Start a loop from the same source file
       codecs.StartOptimizedLoad();

      for (int i = 1; i < 10; i++)
      {
         using (RasterImage image = codecs.Load(srcFileName, i))
         {
            string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "out_" + i.ToString() + ".jpg");
            // Save as the destination image
            codecs.Save(image, destFileName, RasterImageFormat.Jpeg411, 24);
          }
      }

      // Finish using the same source file.
      codecs.StopOptimizedLoad();
   }
}

The above example uses filter data to convert all of the pages of a PDF file. For PDF files, the speed improvement will be noticeable when large files (1000 pages or more) are converted. For other file formats, the speed improvement can be significant even with fewer pages (as few as 10 pages).

TIFF/BigTIFF files use a simpler mechanism (the IFD, or file offset of each page). For more information about using the IFD, refer to Loading and Saving Large TIFF/BigTIFF Files.


Error processing SSI file