Jpeg2000 (jp2) files take very long time to to load/save

Using Aspose sample file (input.jp2) and Aspose sample code (.NET), the following is taking a very long time to process (over 8 minutes):

Input file: https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Multipage/Input.jp2

Code from https://products.aspose.com/imaging/net/conversion/jpeg2000-to-bmp/:

using Aspose.Imaging;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;

//https://github.com/aspose-imaging/Aspose.Imaging-for-.NET/blob/master/Examples/Data/Multipage/Input.jp2
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
string templatesFolder = @"c:\Users\USER\Downloads\templates\";

// Load the jpeg2000 file in an instance of Image
using (var image = Aspose.Imaging.Image.Load(Path.Combine(templatesFolder, @"Input.jp2")))
{
   // Create an instance of BmpOptions
   var exportOptions = new Aspose.Imaging.ImageOptions.BmpOptions();

   // Save jpeg2000 to bmp
   image.Save(Path.Combine(templatesFolder, "output.bmp"), exportOptions);

   File.Delete(Path.Combine(templatesFolder, "output.bmp"));
}

Please advise. I have even tried playing around with BufferSizeHint and CacheData().

Thanks,
Mark

@markmanley.adlib

It sounds like you’re experiencing significant delays when loading and saving JPEG2000 (JP2) files using Aspose. Here’s a structured approach to address the issue:

Cause: Large or complex JP2 files can lead to performance delays during processing.

Solution: Here are several steps you can take to potentially improve performance:

  1. Check File Size and Complexity: Test with smaller or simpler JP2 files to determine if the performance improves.

  2. Optimize Memory Usage: Set a memory limit for image processing operations. This can help manage resources better and potentially speed up the process. For example:

    using (var image = Image.Load("input.jp2", new LoadOptions() { BufferSizeHint = 50 })) // Adjust buffer size as needed
    {
        var exportOptions = new BmpOptions();
        image.Save("output.bmp", exportOptions);
    }
    
  3. Use Irreversible Compression: If your application allows it, consider using irreversible compression options when saving JPEG2000 images, as this can lead to faster processing times.

  4. Profile Your Code: Utilize profiling tools to identify any bottlenecks in your code, which will help you understand where the delays are occurring.

  5. Update Aspose Library: Ensure you are using the latest version of the Aspose.Imaging library, as performance improvements and bug fixes are regularly released.

Next Steps: If you continue to experience issues, please provide more details about the specific file and environment you’re working with. This information will help me assist you further.

Thank you for your patience, and I look forward to your response!

That AI response is not helpful. I have provided all the details and links to sample file. Please have a human look into this.

I have the latest (25.8) library as well.

The same file takes ~1 second to load and save using a tool like IrfanView.

Thanks!
Mark

@markmanley.adlib , we are reviewing your request. You will be answered shortly!

@markmanley.adlib ,
I have tested the used code and the Jpeg2000 image using latest version. I found that execution takes seconds on my PC rather that minutes.
Would you mind to share some additional info on how to reproduce such your case?

I see the difference. We were having issues and tried using BufferSizeHint.

If you set this, you will see our issue. Is that a bug or is BufferSizeHint only supported in certain cases?

using (var image = Aspose.Imaging.Image.Load(inputPath, new LoadOptions() { BufferSizeHint = 50}))

@markmanley.adlib
We have opened the following new ticket in our internal issue tracking system to investigate and speed up Jpeg2000 decoding. We will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): IMAGINGNET-6339

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.

Our apologies for any inconvenience!