We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

TIFF split and resize operation is very slow (C# .NET)

Hello,
We’re evaluating Aspose.Imaging as a potential replacement for our current image processing library. One of the operations we do very frequently is splitting a multi-page TIFF file and saving each frame with a different size as a PNG. We’ve came up with a very simple code which does it in Aspose.Imaging, but the problem is that it’s incredibly slow - splitting a 10 page TIFF and resizing each frame takes almost 40 seconds (!), while our existing solution completes exactly the same operation roughly in 6 seconds.

Can you please see the code below and let me know if we’re missing something?

using (var asposeImg = (TiffImage)Aspose.Imaging.Image.Load(inputFilePath))
        {
            for(var i = 0; i < asposeImg.Frames.Length; i++)
            {
                TiffFrame frame = asposeImg.Frames[i];
                frame.Resize(2550, 3300);
                frame.Save($@"C:\{i}.png", new PngOptions());
            }
        }

Here’s the TIFF file we’re using for the test:
multipage_tiff_example.zip (601.3 KB)

@grzegorz.brose,

I have observed the sample code shared by you and it seems fine. We need to investigate this further on our end. An issue with ID IMAGINGNET-3729 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

@grzegorz.brose

on our using latest version of Aspose.Imaging, the sample code executed for 63 seconds to process 10MB_Tif.tif that has 44 pages and 10MB size. But using parallel tasks execution, we managed to get the same result in 20 seconds:

using (var asposeImg = (TiffImage)Aspose.Imaging.Image.Load(inputFilePath))
{
    System.Threading.Tasks.Parallel.ForEach(asposeImg.Frames,
        (frame, _, index) =>
            {
                frame.Resize(2550, 3300);
                frame.Save($@"C:\{index}.png", new PngOptions());
            });
}

I hope that this technique will be useful for your application.

UPD Performance results for “multipage_tiff_example.tif” image from customer:

  • 12,5 seconds for customer code;
  • 3,7 seconds for code with parallelization.

In general, there is a multiple increase in performance when using parallelization. This value will depend on the processor (>3 in my case).