Technical FAQs

Question

The logging for ImageGear C & C++ Deployment Packaging Wizard (DPW) is showing different output for some components since v19.3, why is this?

In ImageGear C & C++ v19.2 and prior, the DPW had additional logging information for the ARTX component in its deployment.log:

Deploying an application that uses the ARTXGUI library of ImageGear
ARTX Component requires the following merge modules to be installed:

Microsoft_VC90_CRT_x86_x64.msm

Microsoft_VC90_MFC_x86_x64.msm

But since v19.3, the logs are no longer telling me to install these modules. Is this a mistake, or are they no longer necessary?

Answer

This was an intentional change on our end, and the Deployment Packaging Wizard (DPW) is working as intended. We made some updates to the DPW in the latest release; one update is that the CRM requirements for CORE (which is required in every project) now also covers the ARTX component. If the DPW is not saying you need additional components to use the ARTX component, then you’ll be fine.

Question

Why do I get a “File Format Unrecognized” exception when trying to load a PDF document in ImageGear .NET?

Answer

You will need to set up your project to include PDF support if you want to work with PDF documents. Add a reference to ImageGear24.Formats.Pdf (if you’re using another version of ImageGear, make sure you’re adding the correct reference). Add the following line of code where you specify other resources:

using ImageGear.Formats.PDF;

Add the following lines of code before you begin working with PDFs:

ImGearFileFormats.Filters.Insert(0, ImGearPDF.CreatePDFFormat());
ImGearPDF.Initialize();

The documentation page linked here shows how to add PDF support to a project.

Question

How do I use a Network Drive path for Image and ART storage in my ImageGear .NET web application?

Answer

In an ImageGear .NET web application, you have to define the location of the images and annotations directory in the storageRootPath and artStorageRootPath configuration property.
In the current version of ImageGear .NET, the storageRootPath and artStorageRootPath do not work with a network drive path \\SERVER-NAME\sharefilename.

The workaround for this would be to create a Symbolic link from a local directory to the network drive directory.

  • To create a symbolic link: Open “Command Prompt” as Administrator and type in > mklink /d "local path" \\SERVER-NAME\sharefilename
  • Pass in the path of the symbolic link as image or art storage root path in your web.config: storageRootPath="local path" artStorageRootPath="local path"

Image compression has become such a ubiquitous aspect of the digital world that the average person doesn’t give it much thought. Even when they encounter textbook compression problems, such as running out of space for photos on their phones, waiting on a slow-loading webpage, or working with an overly pixelated image, they may not consider how effective compression techniques could resolve these issues.

Today’s software developers, by contrast, spend a lot of time thinking about how to incorporate better compression solutions into their applications. That’s why they frequently turn to image compression SDKs to help their end users better manage large and highly-detailed image files.

The Enduring Need for Image Compression

Although advancements in hard drive technology and easily scalable cloud storage have reduced many traditional data management concerns, large image files can still pose significant challenges. Many organizations that can’t utilize cloud storage options for compliance reasons or find the cost of those platforms prohibitively high. 

While they may be able to add more on-premises storage easily enough, this option can also quickly become quite costly. Companies often need to procure much more storage than they may need on a day-to-day basis in order to meet redundancy requirements. Scaling physical storage also locks firms into burdensome equipment refresh cycles.

But simply storing images is only part of the challenge of data management. Large files are more difficult to move, even if an organization has a customized solution in place. If images can’t be shared quickly and easily through a secure platform, users may turn to riskier third-party applications.

Image compression alleviates these problems by reducing the overall size of image files. By compressing image files, organizations can maximize their storage potential and share files more easily. Image compression can also improve website and application performance by reducing the time it takes to load images. 

Although there are many different methods of compressing images, they all involve algorithms that use a variety of shortcuts to reduce the overall size of pixel data. In some instances, compression involves the elimination of image data, which can degrade the image quality and make it impossible to return to its original size (lossy or irreversible compression). Other techniques retain the original image data, but can’t achieve the same level of compression (lossless or reversible compression). 

Image Compression SDKs and Your Applications

While there are many compression options available in commercial imaging software, organizations often need the ability to compress image files within their core business applications without any external dependencies. Opening an image file with another program not only takes additional time and disrupts efficient workflow, but it also creates the potential for security risks and version confusion.

Consider, for instance, a medical provider that needs to send a high-resolution MRI scan to another provider. If the file is too large to deliver electronically, someone may try to get around the problem by using another program to compress the scan and then send it as an attachment over email or share it through a cloud platform. Suddenly, the confidential image file has been accessed by potentially vulnerable third-party applications, which creates a serious compliance issue. To make matters worse, the compressed image may not be associated with the patient’s file in the EHR system. And that’s not even getting in the question of whether or not the compression technique used damaged the image integrity!

An image compression SDK like ImageGear allows developers to integrate the ability to compress and convert image files into their applications without compromising security, efficiency, or quality. Optimized, standards-based compression libraries with support of formats like TIFF, PDF, PDF/A, JPEG 2000, JPEG, and DICOM deliver fast compression/decompression capabilities while ensuring that images remain high quality. 

The primary advantage of integrating image compression capabilities directly into an application is the lack of third-party dependencies. This is crucial for software that is gathering and managing image files because it doesn’t cause any workflow disruptions. With an image compression SDK integration, image files can be shrunk down to more manageable sizes programmatically, which aids significantly in automated processes. Since the images are being compressed entirely within the application, it’s also easier to maintain strict version and access control throughout the life cycle of the file.

Image Compression SDKs vs Open Source Solutions

Many developers turn to open source compression libraries when looking to integrate image compression features into their applications. While this often seems like an easy, low cost solution, open source codecs can lead to unforeseen problems over time. Since many of them are not actively maintained, troublesome bugs can go unresolved and security gaps can create serious privacy risks.

One infamous example of this problem involved the widely used “Cornell Codec,” one of the first open source libraries that supported lossless JPEG compression. Developed in 1994, it was quickly adopted by many healthcare applications that needed to compress high-resolution medical images like MIRIs, CT scans, and X-Rays. 

Unfortunately, the codec had a problem. When it compressed images into DICOM files (the industry standard used in medical imaging applications), it produced an error that made them unreadable when they were decompressed. Since the Cornell Codec was an open source solution embedded into numerous applications, the problem went unresolved for many years until Accusoft developed a code based workaround for our customers.

By choosing a well-supported image compression SDK like ImageGear for their application’s compression needs, developers can rest easier knowing that they’re deploying a tried and true solution that won’t create unexpected problems for their customers. Another benefit of a comprehensive image compression SDK is that it will provide a variety of compression libraries that can accommodate almost any file type and use case. ImageGear, for example, supports more than a dozen unique image compression types, including JPEG (lossy/lossless/progressive), RAW, ASCII, and Deflate.

ImageGear: More Than an Image Compression SDK

Image compression is just one of ImageGear’s many powerful document and image processing features. A versatile code-based solution, ImageGear allows developers to quickly integrate image conversion and cleanup features to their application along with editing, annotation, viewing, scanning, and printing capabilities. With support for a huge number of today’s leading document and image file formats as well as medical imaging support with ImageGear Medical, this SDK toolkit delivers the functionality developers need to get their applications to market faster. See what ImageGear can do for your application today by downloading a free trial.

Question

How do I use a Network Drive path for Image and ART storage in my ImageGear .NET web application?

Answer

In an ImageGear .NET web application, you have to define the location of the images and annotations directory in the storageRootPath and artStorageRootPath configuration property.
In the current version of ImageGear .NET, the storageRootPath and artStorageRootPath do not work with a network drive path \\SERVER-NAME\sharefilename.

The workaround for this would be to create a Symbolic link from a local directory to the network drive directory.

  • To create a symbolic link: Open “Command Prompt” as Administrator and type in > mklink /d "local path" \\SERVER-NAME\sharefilename
  • Pass in the path of the symbolic link as image or art storage root path in your web.config: storageRootPath="local path" artStorageRootPath="local path"
Question

I encounter an Unhandled Exception error, as shown below, in ImageGear when trying to load a page into the recognition engine.

Error Message: An unhandled exception of type
‘ImageGear.Core.ImGearException’ occurred in ImageGear22.Core.dll

Additional information: IMG_DPI_WARN (0x4C711): Non-supported
resolution. Value1:0x4C711

What is causing this and how can I fix it?

Answer

This is probably because the original image used to create the page didn’t have a Resolution Unit set.

Resolution unit not set in original image

To fix this, check if the page has a Resolution Unit set. If it does not, set it to inches. You should also set the DPI of the image as those values were probably not carried over from the original image since the Resolution Unit wasn’t set. The following code demonstrates how to do this.

// Open file and load page.
using (var inStream = new FileStream(@"C:\Path\To\InputImage.jpg", FileMode.Open, FileAccess.Read, FileShare.Read))
{
    // Load first page.
    ImGearPage igPage = ImGearFileFormats.LoadPage(inStream, firstPage);

    if (igPage.DIB.ImageResolution.Units == ImGearResolutionUnits.NO_ABS)
    {
        igPage.DIB.ImageResolution.Units = ImGearResolutionUnits.INCHES;
        igPage.DIB.ImageResolution.XNumerator = 300;
        igPage.DIB.ImageResolution.XDenominator = 1;
        igPage.DIB.ImageResolution.YNumerator = 300;
        igPage.DIB.ImageResolution.YDenominator = 1;
    }

    using (var outStream = new FileStream(@"C:\Path\To\OutputImage.jpg", FileMode.OpenOrCreate, FileAccess.ReadWrite))
    {
        // Import the page into the recognition engine.
        using (ImGearRecPage recognitionPage = recognitionEngine.ImportPage((ImGearRasterPage)igPage))
        {
            // Preprocess the page.
            recognitionPage.Image.Preprocess();

            // Perform recognition.
            recognitionPage.Recognize();

            // Write the page to the output file.
            recognitionEngine.OutputManager.DirectTextFormat = ImGearRecDirectTextFormat.SimpleText;
            recognitionEngine.OutputManager.WriteDirectText(recognitionPage, outStream);
        }
    }
}
Question

ImageGear .NET v24.6 added support for viewing PDF documents with XFA content. I’m using v24.8, and upon trying to open an XFA PDF, I get a SEHException for some reason…

SEHException

Why might this be happening?

Answer

One reason could be because you need to execute the following lines after initializing the PDF component, and prior to loading an XFA PDF:

// Allow opening of PDF documents that contain XFA form data.
IImGearFormat pdfFormat = ImGearFileFormats.Filters.Get(ImGearFormats.PDF);
pdfFormat.Parameters.GetByName("XFAAllowed").Value = true;

This will enable XFA PDFs to be opened by the ImageGear .NET toolkit.

Question

I want to re-arrange the page order of a PDF. I’ve tried the following…

var page = imGearDocument.Pages[indx].Clone();

imGearDocument.Pages.RemoveAt(indx); //// Exception: "One or more pages are in use and could not be deleted."

imGearDocument.Pages.Insert(newIndx, page);

But an exception is thrown. Somehow, even though the page was cloned, the exception states that the page can’t be removed because it’s still in use.

What am I doing wrong here?

Answer

If you’re using an older version of ImageGear .NET, you may run into this exception when you clone the page. Some of the resources between the original and the clone are still shared, which is why this happens.

Starting with ImageGear .NET v24.8, this no longer happens, and the above code should work fine.

If you still need to use the earlier version, you can use the InsertPages method instead.

Question

In ImageGear, why am I running into AccessViolationExceptions when I run my application in parallel?

Answer

This issue can sometimes occur if ImGearPDF is being initialized earlier in the application. In order to use ImGearPDF in a multi-threaded program, it needs to be initialized on a per-thread basis. For example, if you have something like this:

ImGearPDF.Initialize();
Parallel.For(...)
{ 
    // OCR code
}
ImGearPDF.Terminate();

Change it to this:

Parallel.For(...)
{
    ImGearPDF.Initialize();
    // OCR code
    ImGearPDF.Terminate();
}

The same logic applies to other ImageGear classes, such as ImGearPage instances or the ImGearRecognition class – you should create one instance of each class per thread, rather than creating a single instance and accessing it across threads. In the case of the ImGearRecognition class, you’ll have to use the createUnique parameter to make that possible e.g.:

ImGearRecognition recEngine = ImGearRecognition(true);

instead of

ImGearRecognition recEngine = ImGearRecognition();
Question

How do I remove XMP Data from my image using ImageGear .NET?

Answer

When removing XMP data in ImageGear, the simplest way to do this is to set the XMP Metadata node to null, like so:

ImGearSimplifiedMetadata.Initialize(); 
doc.Metadata.XMP = new ImGearXMPMetadataRoot();

Or, you can traverse through the metadata tree and remove each node from the tree:

// Example code. Not thoroughly tested
private static void RemoveXmp(ImGearMetadataTree tree)
{
ArrayList toRemove = new ArrayList();
foreach (ImGearMetadataNode node in tree.Children)
{
    if (node is ImGearMetadataTree)
        RemoveXmp((ImGearMetadataTree)node);

    if (node.Format != ImGearMetadataFormats.XMP)
        continue;

    toRemove.Add(node);
}

foreach (ImGearMetadataNode node in toRemove)
    tree.Children.Remove(node);
}