0

I am using Aspose.Imaging 19.11.0.0 for manipulating the Tiff Images with Compression JPEG, But here If I have 10MB+ sized tiff files(having 50 pages) then in this case it is taking 30 to 40 minutes to rotate these all tiff pages and application went on not responding mode. In my code, suppose I have 50 pages in Tiff image files, then from client application I am iterating each pages through foreach loop and sending corresponding rotate method for each page on server side for rotation, I know the one of the factor for time consuming is the sending each pages instead of all pages at once, but when I debugged the code then found that tiffImage.Save(Stream, tiffOptions) is taking more time for each page also.

Below are the server side code for rotating the page using JPEG compression , Here below RotatePageUsingAspose() method is called each time for all pages, means suppose I have selected only 3rd page out of 50 then it is being called only one time for selected page with parameter pageNumber =3 and rotation degree = 90 degree In this case, means rotating the 3rd page and saving this page is also taking almost 1 minute,which is far too slow.

Server side code for rotation:

private void RotatePageUsingAspose(int pageNo, RotationDegrees rotationDegree)
  {
     float angleOfRotation = (float)rotationDegree;

     // Auto mode is flexible and efficient.
     Cache.CacheType = CacheType.Auto;

     // The default cache max value is 0, which means that there is no upper limit.
     Cache.MaxDiskSpaceForCache = 1073741824; // 1 gigabyte
     Cache.MaxMemoryForCache = 1073741824; // 1 gigabyte

     // Changing the following property will greatly affect performance.
     Cache.ExactReallocateOnly = false;

     TiffOptions tiffOptions = new TiffOptions(TiffExpectedFormat.TiffJpegRgb);

     //Set RGB color mode.
     tiffOptions.Photometric = TiffPhotometrics.Rgb;
     tiffOptions.BitsPerSample = new ushort[] { 8, 8, 8 };
     try
     {
        using (TiffImage tiffImage = (TiffImage)Image.Load(Stream))
        {
           TiffFrame selectedFrame = tiffImage.Frames[pageNo - 1];
           selectedFrame.Rotate(angleOfRotation);
           tiffImage.Save(Stream, tiffOptions);
        }
     }
     finally
     {
        tiffOptions.Dispose();
     }
  }

I have raised the same question to Aspose.Imaging team but they have not provide the solution for this yet.

Kindly suggest the improvements for above code for saving the pages in efficient manner. If possible please provide the approach to achieve this.

  • Are you rotating the images in place? It might be more efficient to create a new file and copy the rotated images to it. – Cris Luengo Dec 26 '19 at 00:32
  • @CrisLuengo , Thank you for reply, Yes, I am rotating the image in place,I think this operation is taking time. Can you please provide the sample code for creating new file and copying the rotating images to it. – Ankit Raman Dec 27 '19 at 07:11

0 Answers0