Image comparison processing time to save output image is too long in .NET

  • About 1-2 minutes to export a image

  • Result saved image
    image.png (6.0 KB)

  • My code:

    public static class GroupDocsApi
    {
        // Function use GroupDocs API to compare words
        public static ChangeInfo[] CompareDoc(string source, string target, string outPut)
        {
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();

            var assembly = Assembly.GetExecutingAssembly();

            // Check the resource name for your license file
            string resourceName = assembly.GetManifestResourceNames().Single(str => str.EndsWith("GroupDocs.Comparison.NET.lic"));
            Console.WriteLine("Path: {0}.", resourceName);

            // Load license from embedded resource
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
            {
                if (stream != null)
                {
                    License license = new License();
                    license.SetLicense(stream);
                }
                else
                {
                    throw new FileNotFoundException("License file not found as embedded resource.");
                }
            }

            Console.WriteLine("Start calculate process time API....");
            // Using Group Docs API to compare word
            using (
                Comparer comparer = new Comparer(source))
            {
                comparer.Add(target);

                // Options for Group Docs API
                CompareOptions compareOptions = new CompareOptions()
                {
                    //MarkNestedContent = true,
                    GenerateSummaryPage = false,
                    MarkChangedContent = true,
                    DetectStyleChanges = true,
                    CompareBookmarks = false,
                    ChangedItemStyle = new StyleSettings()
                    {
                        HighlightColor = System.Drawing.Color.Yellow,
                        ShapeColor = System.Drawing.Color.LightYellow,
                    },
                    InsertedItemStyle = new StyleSettings()
                    {
                        HighlightColor = System.Drawing.Color.Aqua,
                        ShapeColor  = System.Drawing.Color.Blue,
                    },
                    DeletedItemStyle = new StyleSettings()
                    {
                        HighlightColor = System.Drawing.Color.Red,
                        ShapeColor= System.Drawing.Color.LightCoral,
                    },

                    DetalisationLevel = DetalisationLevel.High
                    //ShowDeletedContent = false,
                    //ShowInsertedContent = false,
                };

                // Start compare with options
                comparer.Compare(outPut, compareOptions);

                stopwatch.Stop();
                TimeSpan elapsedTime = stopwatch.Elapsed;
                Console.WriteLine("Time process API: " + elapsedTime.ToString());

                ProcessBar.UpdateProcessBar(60);    // Percent for process bar

                // Get changes of word
                ChangeInfo[] changes = comparer.GetChanges();

                int[] pageNumbers = Functions.GroupChangesByPage(changes).Keys.ToArray();

                Stopwatch stopwatch1 = new Stopwatch();
                stopwatch1.Start();

                CreatePageImage(outPut, pageNumbers);

                stopwatch1.Stop();
                TimeSpan elapsedTime1 = stopwatch1.Elapsed;
                Console.WriteLine("Time process create images: " + elapsedTime1.ToString());

                return changes;
            }
        }

        public static void CreatePageImage(string outPut, int[] pageNumbers)
        {
            FileStream fileStream = null;
            try
            {
                fileStream = File.OpenRead(outPut);
                Document document = new Document(fileStream);
                string folderTempPath = Storage.FolderTempPath;
                PreviewOptions previewOptions = new PreviewOptions(pageNumber =>
                {
                    var pagePath = Path.Combine(folderTempPath, $"result_{pageNumber}.png");
                    return File.Create(pagePath);
                });
                previewOptions.PreviewFormat = PreviewFormats.PNG;
                previewOptions.PageNumbers = pageNumbers;
                document.GeneratePreview(previewOptions);
            }
            finally
            {
                ProcessBar.UpdateProcessBar(80);    // Percent for process bar
                fileStream.Close();
            }
        }
    }

@FPT008

Could you please share following details and we’ll investigate this issue:

  • GroupDocs.Comparison for .NET API version
  • Sample/problematic source and target files

API Version is GroupDocs.Comparison 24.12.1-alpha-20250110063050
@atir.tahir

@FPT008

Could you please also share the source/target files using that issue could be reproduced?

i split input file input 4 zip files, pls extract and check help me

data.7z.zip (3.0 MB)

data.7z (2).zip (3.0 MB)

data.7z (3).zip (3.0 MB)

data.7z (4).zip (1.3 MB)

1 Like

@FPT008
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): COMPARISONNET-4294

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

thank you, please fix it soon help us @atir.tahir

1 Like

Processing save image so long, please improve help us. Thank youu

@FPT008

We are already investigating this issue. You’ll be notified in case of any update.

1 Like

Thank you for your update. Could you please expedite the bug fix process? It’s crucial for us to resolve this issue as soon as possible. @atir.tahir

@FPT008

We are currently addressing this issue, which is dependent on the resolution of the another internal ticket. Once that ticket is resolved, your issue will be fixed.

Hi @FPT008 ,
Thank you for your report.

Could you please clarify which .NET GroupDocs.Comparison version you are using in your sample? The issue related to the slow rendering of Word pages into images is already under investigation.

Additionally, I noticed that the latest .NET GroupDocs.Comparison NuGet package seems to take an unexpectedly long time to perform the file comparison:

comparer.Compare(outPut, compareOptions);

(specifically for input1_refactor.docm and input2_refactor.docm you provided). This suggests that there might be an additional issue affecting the comparison process.

Could you please share how long the comparison takes on your side? This information will help us further analyze the problem.

Looking forward to your response.